Commit Graph

914 Commits

Author SHA1 Message Date
Mikolaj Wielgus a9cb7f8848 fix(router/navmesh): Use union-find to have all overlapping navnodes actually added 2025-08-28 17:15:28 +02:00
Mikolaj Wielgus 0f4bf1b0be fix(router/navmesh): Make sure all clearance-intersecting navnodes have the same edges
This does not yet fully fix the problem with routing around SMD pads
failing, but is a step forward.
2025-08-28 11:35:20 +02:00
Mikolaj Wielgus 41438eeccc feat(drawing/gear): Implement finding next and previous gear in chain for fixed dots 2025-08-26 00:23:48 +02:00
Mikolaj Wielgus 310e983b1d refactor(drawing/drawing): Move infringement and collision detection to drawing/query 2025-08-25 02:23:02 +02:00
Mikolaj Wielgus ca4a2d1cbf refactor(drawing/query): Rename collect.rs to query.rs, change trait to direct impl 2025-08-24 22:31:10 +02:00
Mikolaj Wielgus 6cb01dbb2a refactor(router/thetastar): Factor out returning status 2025-08-24 00:12:45 +02:00
Mikolaj Wielgus fca8e44269 feat(router/router): Backtrack if initial parent was on the same compound 2025-08-24 00:12:38 +02:00
Mikolaj Wielgus b21f77c9ab feat(router/thetastar): Transition state for each backtrack step for better debugging 2025-08-23 12:09:45 +02:00
Mikolaj Wielgus 5a1cb564dc refactor(router/thetastar): Backtrack not once, but repeatedly, if condition is met 2025-08-23 12:09:45 +02:00
Mikolaj Wielgus 676c24a428 fix(math/bitangents): Calculate bitangents even for intersecting circles
This fixes the bug where the router was failing to draw around SMD pads.
2025-08-23 12:07:06 +02:00
Mikolaj Wielgus cc6065099b fix(router/thetastar): Don't forget to rm. probe when there's shorter path already
This fixes a fatal race condition that made tht_de9_to_tht_de9 always
fail since 7eff7ad9f0a24a9688ab5235f01115f7c85b1ff4.
2025-08-19 15:55:20 +02:00
Mikolaj Wielgus 7bb1a1efbc docs: Add some comments warning about race conditions, rename some identifiers 2025-08-19 15:55:20 +02:00
Mikolaj Wielgus 3738bacf6f fix(math/bitangents): Calculate bitangents even for intersecting circles
This fixes the bug where the router was failing to draw around SMD pads.
2025-08-19 15:46:12 +02:00
Mikolaj Wielgus 7fbfed710c refactor(drawing/guide): Make method names somewhat clearer 2025-08-15 23:50:11 +02:00
Mikolaj Wielgus 177c8abb18 refactor(drawing/guide): Instead of trait, just impl guide methods on `Drawing` 2025-08-15 23:31:23 +02:00
Mikolaj Wielgus 9819879617 feat(topola-egui): Display guide-circles on debug overlay 2025-08-15 16:18:31 +02:00
Mikolaj Wielgus fac52f9d8b fix(drawing/drawing): Don't infringe on and from loose dots
These resulted in false positives for line-of-sight paths.
2025-08-12 22:04:21 +02:00
Mikolaj Wielgus 191e646d68 refactor(math/line): Rename `NormalLine` to `LineInGeneralForm`
The previous name sounded as if it was a normal (to some surface), which
is not the case.
2025-08-12 20:01:16 +02:00
Mikolaj Wielgus 987a4c6e9e fix: Flip by X instead of rotating by 180 degrees
Obviously -- flip is undone by a flip, not a rotation. This corrects the
previous commit.
2025-08-11 21:15:40 +02:00
Mikolaj Wielgus ac7b24f939 refactor(autorouter/autoroute): Store vecs of edits instead of large edits
This results in a large copy, but it should be possible to refactor the
code later to get rid of this.
2025-08-10 11:30:50 +02:00
Mikolaj Wielgus 5bff83ecbd refactor: Add method to join iterable of edits into one edit 2025-08-09 22:55:45 +02:00
Ellen Emilia Anna Zscheile 6f7586227c feat(board/edit): Edit structures should implement Default trait 2025-08-09 22:44:33 +02:00
Mikolaj Wielgus 791291b82e feat(router/draw): Try to add canes before trying to squeeze them through 2025-08-09 21:08:10 +02:00
Mikolaj Wielgus 83285dde6d feat(drawing/drawing): Make it possible to have multiple outers for each gear 2025-08-09 21:08:10 +02:00
Mikolaj Wielgus 6317d8b08a feat(geometry/geometry): Create outward bend walker, use it for R-tree updates
Drawing and above abstraction layers do not use it yet, but this will
change soon.
2025-08-09 21:08:10 +02:00
Ellen Emilia Anna Zscheile 8732ee7fbb refactor(geometry/edit): Put reverse and merge functionality into trait (DRY) 2025-07-20 12:40:56 +02:00
Mikolaj Wielgus 09c98f2d17 feat(autorouter/autoroute): Add option to toggle permutation
Updated with the following command in Fish shell:

```
for f in tests/**.cmd; jq ".done?.[].Autoroute[1].permutate |= false" $f | sponge $f; end
```
2025-07-19 21:42:47 +02:00
Mikolaj Wielgus d181c7df1b feat(autorouter/autoroute): Implement basic brute-force permutator
Permutates if and until a solution is found. Does not do optimization
so far.

Thanks to this, it is now possible to route the DE-9 to DE-9 test
without having to find the correct sequence of autorouting jobs.
2025-07-19 21:31:31 +02:00
Mikolaj Wielgus d7129354a1 feat(autorouter/autoroute): Record band assigns so undo actually works
Aborting the autoroute stepper was unimplemented and it would make the
autorouting job finish instead. This is fixed now.
2025-07-17 21:08:42 +02:00
Mikolaj Wielgus 1cc75a79e8 feat(autorouter/autoroute): Make it possible to abort autoroute stepper
Aborting the autoroute stepper was unimplemented and it would make the
autorouting job finish instead. This is fixed now.
2025-07-17 12:50:51 +02:00
Mikolaj Wielgus 2f4dac223c fix(geometry/with_rtree): Do not remove only-modified dots when applying edit
This fixes a panic when undoing some bands.

180952c94f1c7c56c2ce5d2bdd3ab672aa0ccfec did not fix this problem
because we did not stop removing modified dots.
2025-07-17 12:49:25 +02:00
Mikolaj Wielgus d6a82d5264 fix(drawing/drawing): Remove temporary recorder in outward bow updating code
I'm skeptical if this actually works, and I see no difference with this
removed. If this breaks the topo-navmesh code, it may be a better option
to just disable squeezing through under bends in it.
2025-07-17 12:49:25 +02:00
Mikolaj Wielgus 4d5fc25ae3 refactor(drawing/drawing): Some minor changes to method naming, comments, contracts 2025-07-17 12:49:25 +02:00
Mikolaj Wielgus 3c9ce32ff2 fix(geometry/edit): Remove `(None, None)` pairs when merging edits 2025-07-17 12:49:25 +02:00
Mikolaj Wielgus 6dc1ea601c fix(geometry/with_rtree): Add edit apply special handling for modified dots
This does not fix the problems I'm encountering, but is an edge case I
should try to cover anyway.
2025-07-17 12:49:25 +02:00
Mikolaj Wielgus 21dd6ffd39 fix(geometry/with_rtree): Debug-assert instead of returning `Err(())` 2025-07-17 12:49:25 +02:00
Mikolaj Wielgus a9c4456a54 fix(geometry/geometry): Debug-assert against failed node and edge removals 2025-07-17 12:49:25 +02:00
Mikolaj Wielgus 42c788063b fix(geometry/edit): Find first gear correctly, don't rely on edge order 2025-07-17 12:49:25 +02:00
Ellen Emilia Anna Zscheile 4fea23c9ac chore: Fix warnings about lifetime annotations 2025-07-17 12:33:31 +02:00
Mikolaj Wielgus 5a0fec9618 fix(geometry/recording_with_rtree): Some more fixes against bend bbox invalidation
1f8ace9c77 did not fix all the bbox
invalidation problems, hopefully this gets this right now.
2025-07-16 19:35:51 +02:00
Mikolaj Wielgus f75bae0666 fix(geometry/recording_with_rtree): Attach bends applied from edit
This was unimplemented, which made both redo and cane removal not work
correctly.
2025-07-16 15:27:56 +02:00
Mikolaj Wielgus 1f8ace9c77 fix(geometry/recording_with_rtree): Do not inadvertedly invalidate bend bboxes
This fixes a crash that was happening when undoing autoroutings.

Bends are still not restored correctly, I will fix that soon.
2025-07-16 00:22:57 +02:00
Mikolaj Wielgus 48fe63a387 feat(geometry/with_rtree): Assert R-tree element removal to be always successful 2025-07-15 23:04:35 +02:00
Mikolaj Wielgus 43005eb864 feat(autorouter/autorouter): Add presorting by ratline intersection count and length
Sadly, this does not work well for the DE-9 to DE-9 test, but it is a
step forward.
2025-07-14 13:26:38 +02:00
Mikolaj Wielgus 0752817538 refactor(autorouter/ratsnest): Split out ratline code to new file, ratline.rs 2025-07-14 13:26:38 +02:00
Mikolaj Wielgus ef78c92506 feat(autorouter/autoroute): Track progress of also past and future ratlines 2025-07-10 22:38:50 +02:00
Mikolaj Wielgus 68d9844d0d feat(topola-egui): Add progress bar for the currently routed ratline
The capability to measure progress will later be useful to choose slower
but better optimization strategies if more time is available.
2025-07-10 22:38:46 +02:00
Mikolaj Wielgus 29dc59df04 refactor(router/navmesh): Split out navmesh triangulation into "prenavmesh" module 2025-07-09 14:55:40 +02:00
Mikolaj Wielgus 9742740b9e refactor(router/navmesh): Factor out some repeating code 2025-07-09 14:55:40 +02:00
Mikolaj Wielgus 5fbb226d08 feat(router/navmesh): Make sure there are quadrinavedges for each trianedge
The problems I noticed in 8095b700167c7445b0bd7c55991f0b6b1c7e2f3d are
resolved now.
2025-07-09 14:55:40 +02:00
Mikolaj Wielgus 3e322d7b34 feat(topola-egui): Add showing of triangulation constraints to debug overlay 2025-07-09 14:55:40 +02:00
Mikolaj Wielgus f3245b9607 feat(router/navmesh): Add constraint edges for loose segs
This does not work entirely correctly. I will investigate in subsequent
commits.
2025-07-09 14:55:40 +02:00
Mikolaj Wielgus 274ad166c1 feat(router/navmesh): Add constraint edges for fixed segs 2025-07-09 14:55:40 +02:00
Mikolaj Wielgus b25ad863ba refactor(autorouter/invoker): Merge debug overlay data traits into one trait
The name of this new trait shall be `GetDebugOverlayData`.
2025-07-06 23:09:08 +02:00
Ellen Emilia Anna Zscheile 5cc1747885 Revert "fix(router/ng/eval): Flip alignment of outer edges"
This reverts commit e3790eb366.
2025-06-30 15:51:25 +02:00
Ellen Emilia Anna Zscheile 185c2972b7 chore(router/ng/mod): Run cargo fmt 2025-06-30 15:26:38 +02:00
Ellen Emilia Anna Zscheile 80a048faaf fix(math/line): Fix offset of 'orthogonal_through' (which didn't match with the 'intersects' sign) 2025-06-30 15:26:08 +02:00
Ellen Emilia Anna Zscheile 30c6df31ab chore(router/ng/mod): Get rid of unnecessary debugging output in calculate_navmesh 2025-06-30 15:16:21 +02:00
Ellen Emilia Anna Zscheile e3790eb366 fix(router/ng/eval): Flip alignment of outer edges
This makes it possible to route some paths, altho it looks really wrong on first glace.
I don't yet know exactly what's going on.
2025-06-30 15:09:28 +02:00
Ellen Emilia Anna Zscheile 38ef4d4a59 refactor(math/line): Put functions regarding NormalLines and Lines into a separate file 2025-06-28 23:08:51 +02:00
Ellen Emilia Anna Zscheile ff03083d65 chore(math/mod): Rename 'beam' to 'ray' in intersection functions 2025-06-28 23:03:09 +02:00
Ellen Emilia Anna Zscheile 59473c36c8 refactor(layout/layout): Put bands_between_* methods into separate file collect_bands.rs 2025-06-28 11:32:38 +02:00
Ellen Emilia Anna Zscheile d3dc826be4 feat: Implement TopoNavmesh DualOuter-DualOuter extraction
This also fixes a sign bug in LineIntersection calculation
2025-06-27 15:15:26 +02:00
Ellen Emilia Anna Zscheile cfde2eac20 fix(planar-incr-embed): Fix Edge lhs vs. rhs association 2025-06-27 15:15:26 +02:00
Ellen Emilia Anna Zscheile ed06170db5 feat: Debug print various TopoNavmesh structures / updates
- feat(autorouter/execution): Debug-print the whole TopoNavmesh on completion
- feat(router/ng/poly): Emit log output on route_to_exit success
2025-06-27 15:15:26 +02:00
Ellen Emilia Anna Zscheile a561b278fc feat(router/ng/router): Implementation of the topological router
- feat(autorouter): Prepare for population of planar Topo-Navmesh with existing routes
  See also issue #166.
- feat(topola-egui): Add dialog for topological navmesh layer selection
- feat(router/ng/eval): Optionally restrict set of allowed TopoNavmesh edges
- fix(router/ng/eval): Use poly_ext_handover
2025-06-27 15:15:24 +02:00
Ellen Emilia Anna Zscheile c8848ef269 refactor(topola-egui): Move InteractiveEvent handling from Viewport into Workspace 2025-06-27 06:51:20 +02:00
Ellen Emilia Anna Zscheile c66089bca9 fix(interactor/interactor): Factor out the logic for on-event activity updates 2025-06-27 06:12:38 +02:00
Ellen Emilia Anna Zscheile a4b1b3893c feat: Add interaction stepper for route building 2025-06-27 06:02:05 +02:00
Mikolaj Wielgus 03ed35cbc4 fix(drawing/drawing): Fix squeezing through under bends by flipping CW/CCW
I don't know what was the original cause of this bug, but this seems to
solve the problem.
2025-06-25 20:11:49 +02:00
Ellen Emilia Anna Zscheile 896deb1777 docs(math/polygon_tangents): Fix `CachedPolyExt` doc-comment 2025-06-12 23:33:30 +02:00
Ellen Emilia Anna Zscheile 03d85b8566 feat(math/polygon_tangents): Implement polygon handover
Fixes #240
2025-06-12 23:33:30 +02:00
Ellen Emilia Anna Zscheile 371d13e7e1 fix(math/polygon_tangents): Fix usual triangle case
See also issue #238.

This does not fix the case where all nodes of the convex hull lie on some tangent.
2025-06-12 23:33:30 +02:00
Ellen Emilia Anna Zscheile bbd8d78089 refactor(math/polygon_tangents): Reduce code duplication 2025-06-12 23:33:30 +02:00
Mikolaj Wielgus 3ec15db5bc docs(router/thetastar): Add some explanatory comments 2025-06-12 16:45:07 +02:00
Mikolaj Wielgus 1630ed1a45 refactor(router/thetastar): Store edge ids in `Vec<...>` instead of `VecDeque<...>` 2025-06-12 16:45:07 +02:00
Mikolaj Wielgus 437e2f96d1 fix(router/navcord): Correctly take into account length of final termseg 2025-06-12 16:45:07 +02:00
Mikolaj Wielgus d0c304adbd feat(router/thetastar): Implement Theta* search algorithm
Closes https://codeberg.org/topola/topola/issues/121
2025-06-12 16:45:07 +02:00
Mikolaj Wielgus 1fea359a40 refactor(router/astar): Rewrite A* like a more typical state machine 2025-06-12 16:45:07 +02:00
Mikolaj Wielgus 0702b7eb8c refactor(router/astar): Use getters instead of `pub` members 2025-06-12 16:45:07 +02:00
Ellen Emilia Anna Zscheile cfd20ed381 feat: Implement line (segment) intersection check 2025-06-11 16:37:57 +02:00
Ellen Emilia Anna Zscheile 1505513552 feat(drawing/drawing): Store boundaries in Drawing 2025-06-10 15:37:47 +02:00
Ellen Emilia Anna Zscheile 3c807b5078 refactor(specctra/design): Resolve image once per component 2025-06-02 22:57:45 +02:00
Ellen Emilia Anna Zscheile 2e84380344 chore(router/draw): Make API of 'extend_head' more ergonomic 2025-06-01 14:02:28 +02:00
Ellen Emilia Anna Zscheile 3ae298e4e9 feat(topola-egui): AppearancePanel active_layer selection should be explicit 2025-06-01 02:16:41 +02:00
Ellen Emilia Anna Zscheile d1bcf22e96 feat(math/polygon_tangents): Add unit tests for triangle case 2025-05-30 21:32:13 +02:00
Ellen Emilia Anna Zscheile c41627b023 chore(math/polygon_tangents): Fix clippy warnings 2025-05-30 21:04:43 +02:00
Ellen Emilia Anna Zscheile 42cf8f3a69 fix(math/cyclic_search): Use classic binary search instead
It is unnecessary to use exponential search here, and the
computation complexity of binary search is easier to understand
and obvious O(log n).
This degrades performance minimally in biased edge cases,
and improves performance in the hopefully common
"roughly half of values are false, and other half is true" case.
2025-05-30 21:04:30 +02:00
Ellen Emilia Anna Zscheile 864cf9085a fix(drawing/band): BandTermsegIndex computation should be fallible
Fixes #221.
2025-05-26 14:51:23 +02:00
Ellen Emilia Anna Zscheile 56cc737b82 fix(autorouter/autoroute): Only route each pin-pin connection at most once
Fixes #219.
2025-05-26 14:17:11 +02:00
Mikolaj Wielgus 8647df026d refactor(geometry/edit): "merge" instead of "apply" edit on another edit
This is just a small terminological distinction.
2025-05-26 02:44:26 +02:00
Mikolaj Wielgus e92864d58b fix(router/astar): Do not panic if navnode visit fails, just skip it
I have renamed some trait functions to make it clearer what they do, and
clarified some comments.
2025-05-25 18:04:18 +02:00
Mikolaj Wielgus 24d119ad04 refactor(router/navmesh): Rename "navvertex" to "navnode"
Easier to pronounce.
2025-05-25 18:01:26 +02:00
Ellen Emilia Anna Zscheile 8d0681c07d fix(topola-egui): Fix click-based selection of pins
- Do intersection calculation between DotShape and Rect=AABB properly
2025-05-21 01:02:12 +02:00
Mikolaj Wielgus 464e8abb89 docs(router/astar): Make some small improvements to docs 2025-05-21 00:29:13 +02:00
Mikolaj Wielgus e79078e971 fix(router/router): Calculate A* navedge cost correctly
The length of the past head depends on what was previously in the same
scan, so it can't be relied on. Instead, we just add the length of the
bend that is immediately before the probe.
2025-05-21 00:29:13 +02:00
Mikolaj Wielgus b75101cb83 fix(router/router): Replace LoS-based A* termination with correctly searched one 2025-05-21 00:29:13 +02:00
Ellen Emilia Anna Zscheile ded1ec8ece fix(router/draw): Undo modification of old cane head on failure 2025-05-20 01:05:05 +02:00
Ellen Emilia Anna Zscheile ee19ae934f fix(drawing/bend): Improve handling of almost equal points in perp_dot_product 2025-05-20 00:13:07 +02:00
Ellen Emilia Anna Zscheile d553fd6ba7 fix(router): attempt to fix autorouter 2025-05-17 16:32:15 +02:00