Commit Graph

203 Commits

Author SHA1 Message Date
Mikolaj Wielgus 9007b850c4 geometry: rename `Index` to `GeometryIndex` 2024-01-16 01:31:36 +00:00
Mikolaj Wielgus d9b94742e4 geometry: split loose segs into lone and sequential (seq) types 2024-01-15 15:56:37 +00:00
Mikolaj Wielgus 8f8f47a41d layout: store component instead of net in weight of each fixed primitive 2024-01-14 14:08:17 +00:00
Mikolaj Wielgus 0c6190e235 cleanup,layout: make connectivity and geometry private and clean up 2024-01-13 22:55:54 +00:00
Mikolaj Wielgus 1af5b96768 deps,graph: split out to new geometry and connectivity graph modules
The geometry graph is where the layout's dots, segs, and bends are
stored. The connectivity graph is where information about connected
components and relations between tem (e.g. which ones are connected with
bands) and information common to all band primitives are stored.

This removes dependency on the Slab library. We may go back to it
sometime in the future if we decide to phase out usage of Petgraph's
`StableDiGraph`.
2024-01-13 20:36:25 +00:00
Tomasz Cichoń 9a4e8357e7 deps: add thiserror and anyhow, reduce boilerplate
This adds rudimentary error messages and unsilences some errors.
2024-01-13 18:58:20 +01:00
Mikolaj Wielgus 0b3fe216db layout: restore infringability in `.move_dot()`
It was temporarily disabled earlier.
2023-12-27 21:56:55 +00:00
Mikolaj Wielgus 90972136da layout: create `.remove_segbend()`, new and now only way to remove
`.remove()` is now private. The dot that terminates a segbend is renamed to "face".
2023-12-27 20:39:04 +00:00
Mikolaj Wielgus 81e316397f layout,main: display attempted shapes that caused probe to fail 2023-12-23 02:32:43 +00:00
Mikolaj Wielgus da8af817bf main: highlight nodes that made the probe fail 2023-12-23 01:03:43 +00:00
Mikolaj Wielgus 9a005c8ba3 main: only color edge if nodes are immediately subsequent in path 2023-12-22 23:36:24 +00:00
Mikolaj Wielgus 95faf96030 router: handle tracer results
Pass the result of tracer probing step to the `.on_probe()` observer
method.

Unwrap the result of `.rework_path()`, as it should never fail as the
previous probe step should have ensured that this step is admissible.
2023-12-22 22:46:07 +00:00
Mikolaj Wielgus b24578ff35 draw: create new error type, `DrawException` 2023-12-22 17:53:38 +00:00
Mikolaj Wielgus 59024d5e74 layout,math: create some error types
We need this for debugging, as we need some better way to display what
intersects what at what moment. Otherwise it takes a lot of effort to
figure out what is going on.

I had to create some type annotations that appear superfluous. Might be
interference from the `contracts` library. This should be investigated.
2023-12-22 05:39:46 +00:00
Mikolaj Wielgus 9a755059c0 mesh: fix finding neighbors and edges from non-triangulation vertices
This fixes a panic caused by lack of implementation of handling of these.
2023-12-19 21:24:11 +00:00
Mikolaj Wielgus 84d5f9c49e layout: implement almost working reworked squeezing-under
I've temporarily removed collision/infringement detection in
`.move_dot()` because it was a lot of effort to get it right. We'll deal
with this later.

There's a panic due to mesh edges not being generated properly from
loose bends. But this commit is already very large, so I'm going to fix
this in the next one.

There's also some nomenclature changes.
2023-12-19 02:22:55 +00:00
Mikolaj Wielgus 5e3248014c graph: create `WraparoundableIndex` enum for wraparoundables 2023-12-17 01:44:00 +00:00
Mikolaj Wielgus 73736fef50 primitive: create `GetWraparound` trait to get the wraparound
Wraparound is either the outer bend or the first rail bend. We need this
trait because some routines can wrap around both fixed and loose
primitives.
2023-12-17 01:43:55 +00:00
Tomasz Cichoń ef593aca78 Replace SDL2_gfx with Pathfinder
Fixes #12
2023-12-16 22:49:46 +01:00
Mikolaj Wielgus 0706a8c258 primitive: Remove traverser objects
Tey were a bad idea. As such objects immutably borrow the layout, one
cannot use tem in a for loop that mutates it.
2023-12-16 13:24:47 +00:00
Mikolaj Wielgus 92834c66c8 graph: Store the offset from the bend immediately below in bend weight 2023-12-16 00:06:13 +00:00
Mikolaj Wielgus 294e6c4f72 graph,layout,primitive: store band index instead of net in loose weights 2023-12-15 01:42:09 +00:00
Mikolaj Wielgus b8f6b32341 graph,layout,primitive: Rename "layers" to "rails"
By "layer" we should be referring to the PCB layers. A "rail" shall be
one in a spatial sequence of parallel and topologically linked tracks,
which together shall be called a "railing".
2023-12-13 17:10:57 +00:00
Mikolaj Wielgus f2991af721 Remove dependency on `enum-as-inner` crate
Fixes https://codeberg.org/mikolaj/topola/issues/13
2023-12-13 14:29:07 +00:00
Mikolaj Wielgus 36710b7a51 tracer: Implement rudimentary wrapping around loose bends
Temporarily disabled bend-seg intersection to make it rudimentarily
work.
2023-11-15 15:42:58 +00:00
Mikolaj Wielgus 60c494a171 draw: Clean up some commented-out code and make types narrower 2023-11-15 01:08:28 +00:00
Mikolaj Wielgus 9fe591d4dc mesh: Make bends vertices, too 2023-11-06 23:22:00 +00:00
Mikolaj Wielgus d6163d3d44 triangulation: Parameterize to make independent from `Mesh` 2023-11-05 20:19:18 +00:00
Mikolaj Wielgus 961fc02678 primitive: Move `.core()` to a trait only implemented by bends 2023-11-05 13:25:28 +00:00
Mikolaj Wielgus 8379470bb1 mesh: Split out `Mesh` into a new `Triangulation` struct
It will be possible for the mesh to contain additional vertices that
aren't part of the Delaunay triangulation. `Mesh` is now a wrapper over
`Triangulation` that implements the same traits, and will be later
adding its own vertices in addition to the ones from triangulation.
2023-11-04 22:49:20 +00:00
Mikolaj Wielgus 66d5b3e605 mesh: Remove `Visitable`, `VisitMap` trait impls
I don't know why the original A* implementation needed tem.
2023-11-04 18:33:14 +00:00
Mikolaj Wielgus 13e38c6889 mesh: Use a tagged graph index as vertex index instead of a Spade handle 2023-11-04 18:33:14 +00:00
Mikolaj Wielgus a6481cb839 band,bow: Remove unused band, bow modules, add new traverser module
Implement a traverser for wrapped bends.
2023-11-04 18:28:12 +00:00
Mikolaj Wielgus 9a5b046724 mesh: Use a `.map()` instead of custom iterator `struct`s 2023-10-31 23:35:33 +00:00
Mikolaj Wielgus a3cedff577 mesh: Make it possible for fixed and loose bends to be vertices
But not adding tem to the mesh yet, as it's going to take some effort.
2023-10-30 18:28:03 +00:00
Mikolaj Wielgus b84dab9d09 layout: Return an iterator over nodes instead of dots
It's more general. Needed because mesh will be also generated from fixed
and loose bends.
2023-10-30 16:05:36 +00:00
Mikolaj Wielgus c46d8c7434 tracer: Starting and finishing is always on a fixed dot 2023-10-30 15:50:35 +00:00
Mikolaj Wielgus 700ffb0096 draw,layout: Move segbend construction to `Layout`
The method to add loose dots is now private.
2023-10-29 16:07:43 +00:00
Mikolaj Wielgus f0e2ba6e3a contracts: Put contract-bound function body in a `try` block if needed
This makes Topola dependent on nightly Rust. If `try` blocks aren't
stabilized before the first release, we'll trivially just undo this
change temporarily, as contracts are just elaborate assertions.
2023-10-29 15:24:41 +00:00
Mikolaj Wielgus 0cf7c718f3 primitive: Remove Option<...> as loose dot is always adjacent to a seg 2023-10-29 06:54:46 +00:00
Mikolaj Wielgus c163716a6a graph,layout,primitive: Use loose primitive variants for traces 2023-10-28 13:18:55 +00:00
Mikolaj Wielgus 4b46b2174b graph,primitive: Remove half-loose seg objects
It was complicating things too much. We would have needed a new `Head`
implementation.
2023-10-27 15:44:36 +00:00
Mikolaj Wielgus 5b2e421493 graph,primitive: Implement new `GetWidth` trait 2023-10-27 09:45:52 +00:00
Mikolaj Wielgus fae2ada334 graph: Remove width from loose seg weights, add it to fixed bend weights 2023-10-27 08:41:03 +00:00
Mikolaj Wielgus 3619c5eab4 layout: Combine primitive creation methods into generics 2023-10-26 14:32:44 +00:00
Mikolaj Wielgus 21ed14ae3d primitive: Implement appropriate `GetEnds` for primitives
Earlier I put a common implementation as a placeholder, now replaced it
with a correct implementation.
2023-10-25 15:29:13 +00:00
Mikolaj Wielgus 6f5a73759a guide: Take unqualified `{Dot,Seg,Bend}Index` unions as arguments 2023-10-25 15:29:13 +00:00
Mikolaj Wielgus cedc2253ca primitive,layout: Remove methods that assume order
There's should be no previous or next primitive, only this end and the
other end.
2023-10-25 15:29:13 +00:00
Mikolaj Wielgus aaad590870 primitive: Remove `.tagged_prev()`, `.tagged_next()` methods
Temporarily commented out band code which relied on tem.
2023-10-25 15:29:13 +00:00
Mikolaj Wielgus 62579d98ba graph: Merge `FixedEnd` and `LooseEnd` into one `Adjacent` 2023-10-25 15:29:13 +00:00
Mikolaj Wielgus d5acfaccb5 primitive: Remove `.prev_bend()` and `.next_bend()` for now
Commented out the experimental code parts that use tem.
2023-10-25 15:29:09 +00:00
Mikolaj Wielgus 0dac23f018 graph,layout: Add creation methods for new primitives and a new label 2023-10-22 05:07:53 +00:00
Mikolaj Wielgus a2531b078d graph,primitive: Split the 3 primitives into 7
`Dot` becomes `FixedDot` and `LooseDot`.
`Seg` becomes `FixedSeg`, `HalfLooseSeg`, and `FullyLooseSeg`.
`Bend` becomes `FixedBend` and `LooseBend`.

The fixed variants differ from the loose variants by being unchangeable
for the router (though probably will be pushable in some cases, but
that's for later). So typically tey're going to be the initial
conditions.

For now only the fixed variants are used even if actually loose, to
split this change into several commits.
2023-10-22 02:05:22 +00:00
Mikolaj Wielgus 2966df6b2c graph: Move boilerplate `impl`s to a new `impl_type` macro 2023-10-21 06:04:41 +00:00
Mikolaj Wielgus 403e3e4f98 graph: Remove the `untag` macro
To accomplish this, some more methods are moved to traits.
2023-10-21 04:37:18 +00:00
Mikolaj Wielgus 4549de098c primitive: Move `tagged_{prev,next}` to a trait
First step towards getting rid of the `untag` macro.
2023-10-20 23:44:20 +00:00
Mikolaj Wielgus 4d20362e00 primitive: Move `.weight()` method to a new `GetWeight` trait 2023-10-20 01:08:58 +00:00
Mikolaj Wielgus e271c82b7e graph: Remove `Tag` trait
Name `Index` enum variants explicitly instead.
2023-10-19 22:41:53 +00:00
Mikolaj Wielgus b52eefb1a3 cleanup: Remove unused imports, formatting 2023-10-19 20:29:31 +00:00
Mikolaj Wielgus 708fbb98f1 graph,primitive: Use enum_dispatch, rely on generics less 2023-10-19 20:07:26 +00:00
Mikolaj Wielgus 4e21ff754d primitive: Move `.shape()` to a new trait `MakeShape` 2023-10-19 06:38:57 +00:00
Mikolaj Wielgus ae9dd23b7c graph: Move `retag` to an enum-dispatched trait 2023-10-18 22:46:18 +00:00
Mikolaj Wielgus b7ff507302 shape: Use `enum_dispatch` for `Shape` 2023-10-18 02:33:03 +00:00
Mikolaj Wielgus 26778e7d47 draw: Comment out bend-flipping code for now
Was causing panics, so let's keep this out of the way for now.
2023-10-17 22:40:47 +00:00
Mikolaj Wielgus e4e6590b4c segbend: When constructing, don't assume bend before face dot 2023-10-17 22:39:48 +00:00
Mikolaj Wielgus 11c7f7fb12 layout: Don't modify bends while tey're in the R-tree 2023-10-17 22:37:40 +00:00
Mikolaj Wielgus 478f630a73 tracer: Don't tuck under inexistent bend 2023-10-17 19:02:26 +00:00
Mikolaj Wielgus 177b8cb231 guide: Return Err(...) instead of panicking 2023-10-17 05:17:07 +00:00
Mikolaj Wielgus 087d1deea0 router: Don't try to route around target dot
This was causing a panic, as it's not possible to route from *around* a
dot *into* the same dot.
2023-10-17 03:55:21 +00:00
Mikolaj Wielgus c9d0b2178e tracer: Add some initial code for squeezing/tucking
Not functional yet.
2023-10-17 03:16:02 +00:00
Mikolaj Wielgus ce72a2ba4b shape: Fix bend-seg intersection
By making zero-length bends non-intersectable.
2023-10-15 01:15:35 +00:00
Mikolaj Wielgus 4ec32c97ba layout: Move R-tree remove out of `debug_assert`
Because of that release builds were panicking.
2023-10-14 04:47:30 +00:00
Mikolaj Wielgus b1ac987d2f shape: Temporarily disable bend-seg intersection as it's bugged 2023-10-14 04:46:16 +00:00
Mikolaj Wielgus bfbad933e2 debug: Create and use `before_probe` observer for search visualization
Also changed `as_*`s to `into_*`s.
2023-10-13 04:00:01 +00:00
Mikolaj Wielgus 4e8e9298e6 astar: Probe neighbors before adding tem to queue 2023-10-12 00:19:38 +00:00
Mikolaj Wielgus af61a6b120 router: Rename `Route` to `Tracer` and simplify related code 2023-10-11 22:23:18 +00:00
Mikolaj Wielgus cc3b537b5c debug: Visualize A* running during interactive routing 2023-10-10 21:09:21 +00:00
Mikolaj Wielgus 7a06a9b02d router: Implement basic cursor following 2023-10-06 22:41:59 +00:00
Mikolaj Wielgus 0e8a6d6e42 Create new `Band` struct to pass around whole bands 2023-10-05 19:52:59 +00:00
Mikolaj Wielgus 0695b1deab draw: Implement flipping the bend if a shorter one is available 2023-09-19 20:56:40 +02:00
Mikolaj Wielgus abf92c7f43 contracts: Fix R-tree envelope invariance test
Violations were not detected if shape changed but not the envelope
(which is the case when bends are flipped).
2023-09-19 20:44:05 +02:00
Mikolaj Wielgus f36f80537f layout: Add invariant testing R-tree envelope invariance 2023-09-19 15:40:26 +02:00
Mikolaj Wielgus efea917cb1 draw: Use `enum_dispatch` to dynamically dispatch `Head` 2023-09-17 16:54:23 +02:00
Mikolaj Wielgus 394510de8d layout: Add contracts for node and edge counts 2023-09-16 18:24:57 +02:00
Mikolaj Wielgus 7d2cff9004 route: Add contracts for path length 2023-09-15 22:48:51 +02:00
Mikolaj Wielgus c94a4c716a draw: Add contracts for node counts 2023-09-15 22:10:29 +02:00
Mikolaj Wielgus 1a271cd89c Add `node_count == size` invariant for `Layout` 2023-09-15 01:30:23 +02:00
Mikolaj Wielgus 23311122b4 draw: Fix on-fail cleanup when drawing segbend 2023-09-05 07:51:27 +02:00
Mikolaj Wielgus 05fc42aa38 draw: Change direction depending on chosen guide tangent 2023-09-05 06:02:11 +02:00
Mikolaj Wielgus f88636057f draw: Choose the shortest guide tangent 2023-09-05 05:51:21 +02:00
Mikolaj Wielgus 49038a4ddb Don't forget to reinsert bend into R-tree if bend extension fails 2023-09-05 04:23:26 +02:00
Mikolaj Wielgus 5f37ff7616 Unroute path whose routing failed in the middle 2023-09-05 02:03:32 +02:00
Mikolaj Wielgus 53c24b1a14 Remove created dot if drawing new seg or bend fails 2023-09-04 05:46:58 +02:00
Mikolaj Wielgus 84a5b81032 Iterate and filtermap over tangents in math module instead of for loop 2023-09-04 00:48:55 +02:00
Mikolaj Wielgus 7d76051cbf Route to goal immediately if a straight path exists at any vertex 2023-09-03 05:43:08 +02:00
Mikolaj Wielgus 73a831ba6d Visualize every routing search step 2023-09-03 01:56:46 +02:00
Mikolaj Wielgus c492bd1dda Parametrize routing using `RouteStrategy` trait 2023-09-02 06:05:13 +02:00
Mikolaj Wielgus bea6d84878 Implement `AstarStrategy` trait to not borrow A* context multiple times 2023-09-02 01:44:35 +02:00
Mikolaj Wielgus b5f9a5957a Route with A* step by step instead of only after A* 2023-09-01 01:35:48 +02:00
Mikolaj Wielgus 1ac8dd2828 Only remove node when collision is detected during placement
As the node is inserted into the R-tree only afterwards.
2023-08-31 22:45:51 +02:00