toolwake 0.2.3__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {toolwake-0.2.3 → toolwake-0.5.0}/CHANGELOG.md +300 -180
  2. {toolwake-0.2.3/src/toolwake.egg-info → toolwake-0.5.0}/PKG-INFO +19 -6
  3. {toolwake-0.2.3 → toolwake-0.5.0}/README.md +210 -197
  4. {toolwake-0.2.3 → toolwake-0.5.0}/pyproject.toml +39 -39
  5. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/__init__.py +51 -51
  6. toolwake-0.5.0/src/toolwake/deposit.py +552 -0
  7. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/geometry.py +411 -258
  8. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/simulate.py +290 -214
  9. {toolwake-0.2.3 → toolwake-0.5.0/src/toolwake.egg-info}/PKG-INFO +19 -6
  10. {toolwake-0.2.3 → toolwake-0.5.0}/tests/test_toolwake.py +1220 -922
  11. toolwake-0.2.3/src/toolwake/deposit.py +0 -232
  12. {toolwake-0.2.3 → toolwake-0.5.0}/LICENSE +0 -0
  13. {toolwake-0.2.3 → toolwake-0.5.0}/MANIFEST.in +0 -0
  14. {toolwake-0.2.3 → toolwake-0.5.0}/examples/demo.py +0 -0
  15. {toolwake-0.2.3 → toolwake-0.5.0}/setup.cfg +0 -0
  16. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/cli.py +0 -0
  17. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/profile.py +0 -0
  18. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/render.py +0 -0
  19. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/serve.py +0 -0
  20. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/tool.py +0 -0
  21. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/toolpath.py +0 -0
  22. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake/viewer.py +0 -0
  23. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake.egg-info/SOURCES.txt +0 -0
  24. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake.egg-info/dependency_links.txt +0 -0
  25. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake.egg-info/entry_points.txt +0 -0
  26. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake.egg-info/requires.txt +0 -0
  27. {toolwake-0.2.3 → toolwake-0.5.0}/src/toolwake.egg-info/top_level.txt +0 -0
@@ -1,180 +1,300 @@
1
- # Changelog
2
-
3
- All notable changes to this project are documented here. Format follows
4
- [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
- [Semantic Versioning](https://semver.org/).
6
-
7
- ## [0.2.3] — 2026-09-18
8
-
9
- Touching is not penetrating. Reported collision counts change.
10
-
11
- ### Fixed
12
- - **Exact tangency was reported as a collision, at random.** With
13
- `bead_radius` and `bead_drop` both h/2 — the setting that makes a bead fill
14
- its layer, which 0.2.1 introduced — a same-layer neighbour passing under the
15
- nozzle wall sits at a clearance of EXACTLY zero. Which side of zero each one
16
- lands on is rounding, not geometry.
17
-
18
- On a real 36 305-row part that put **4 677 rows, 12.9% of the file**, on the
19
- wrong side and reported them as collisions. Every one was blamed on the
20
- cannula, every culprit bead was a same-layer neighbour 0.066–0.093 mm away
21
- laterally — under the wall, outside the bore — and every penetration depth
22
- printed as `-0.0000 mm`.
23
-
24
- `Result.n_hits` and `Result.status` now ignore anything shallower than
25
- `CONTACT_TOL` (1e-12 m), which is six orders of magnitude above
26
- double-precision noise on metre-scale coordinates and seven below anything
27
- this models. `report()` reports such a row as `0.0` rather than `-0.0`.
28
- - **A zero threshold reported tangencies as "close".** With no warning band,
29
- a clearance of -1e-13 satisfied both "not penetrating" and "below the
30
- threshold", so a clean result came back as `warn`. A threshold of zero now
31
- means what it says: only penetration counts.
32
-
33
- ## [0.2.2] — 2026-09-18
34
-
35
- Bounds the size of the viewer page. No reported number changes.
36
-
37
- ### Fixed
38
- - **The viewer inlined every deposited bead, so the page grew without limit.**
39
- Frames were capped at 400; beads were not capped at all. A 2 674-row path
40
- already produces a 1.2 MB page, and a 100 000-row one would produce tens of
41
- megabytes — which is a problem the moment anyone raises their row budget and
42
- tries to embed the result in an iframe.
43
-
44
- `to_html_str` now takes `max_beads` (default 20 000) and decimates the drawn
45
- wake on the same rule as frames: sample evenly, and never drop a bead
46
- something collided with. Purely cosmetic — the report is computed from the
47
- full deposit, and nothing on the page claims a bead count.
48
-
49
- ## [0.2.1] — 2026-09-18
50
-
51
- Finishes 0.2.0. That release fixed the tool's geometry; this one fixes the
52
- material's. Reported clearances change again.
53
-
54
- ### Fixed
55
- - **The bead was round at the bore diameter, so it was taller than its own
56
- layer.** A bead laid at layer height h is squashed to h and spreads
57
- sideways; kept round it pokes up through where the nozzle will sit on the
58
- next pass. On a 0.036 mm-layer slab with a 0.09 mm bore that was 498 rows
59
- reported, 391 of them blamed on material exactly one layer below.
60
- - **The bead was centred on the toolpath, i.e. in the nozzle TIP's own plane.**
61
- Material leaving the bore fills the gap between the previous layer's top and
62
- the nozzle face, occupying [z - h, z] — its centre is h/2 down. Straddling
63
- the face's plane, any same-layer neighbour passing under the wall reported a
64
- collision of exactly one bead radius: tangent contacts dressed up as
65
- penetrations. 41 rows on the same slab, every one at exactly -bead_radius,
66
- which is what gave it away.
67
-
68
- Rows reported as penetrating, across both releases:
69
-
70
- | toolpath | 0.1.1 | 0.2.0 | 0.2.1 |
71
- |---|---|---|---|
72
- | LightPipeRobotTest | 7 | 0 | **0** |
73
- | test_infill | 2 193 | 0 | **0** |
74
- | small_slab | 1 224 | 498 | **0** |
75
-
76
- Every G-code file in the reference set now reports clear.
77
-
78
- ### Added
79
- - `simulate(bead_radius=..., bead_drop=...)` — the laid bead's size, and where
80
- it sits relative to the nozzle face. `bead_drop` is applied along the TOOL
81
- axis, not -Z, so it stays correct on a non-planar move. Explicit arguments
82
- rather than inferred from the path: only the caller knows whether a Z step
83
- is a layer or a ramp.
84
-
85
- ## [0.2.0] — 2026-09-18
86
-
87
- Reported clearances change. The TOOL was modelled with two pieces of geometry
88
- it does not have, and both made it collide with the print it was making. The
89
- BEAD had two of its own; those are 0.2.1.
90
-
91
- ### Fixed
92
- - **Tool sections were capsules, so the tool reached below its own tip.** A
93
- capsule's hemispherical cap bulges a full radius past its endpoint, so a
94
- 0.095 mm-radius cannula occupied 0.095 mm of space beneath the nozzle — and
95
- the space beneath the nozzle is the part. On a 0.06 mm-layer print that
96
- swallowed the two layers underneath on nearly every row: 2 193 of 2 674 rows
97
- reported as collisions, worst -0.14 mm, every one blamed on the cannula
98
- (2 177 of them by material *below* the tip). Sections are now flat-ended
99
- `Cylinder`s. Beads stay capsules: extruded material does have rounded ends.
100
- - **The cannula was modelled solid, so the bore counted as an obstacle.** A
101
- needle is a tube. Material under an open bore — the bead being laid, and the
102
- layer being laid onto — is in the hole, not against the wall. `Section` now
103
- takes `r_inner` and `Cylinder` an `inner_radius`. `blunt_cannula` already
104
- accepted `inner_d` and silently discarded it, which is how the bore went
105
- missing.
106
-
107
- On the three reference toolpaths, rows reported as penetrating:
108
-
109
- | toolpath | 0.1.1 | flat tip | + open bore |
110
- |---|---|---|---|
111
- | LightPipeRobotTest | 7 | 2 | **0** |
112
- | test_infill | 2 193 | 16 | **0** |
113
- | small_slab | 1 224 | 1 218 | 498 |
114
-
115
- `small_slab`'s remaining 498 are the bead model, not the tool; fixed in 0.2.1.
116
-
117
- ### Added
118
- - `Cylinder` — flat-ended, optionally hollow, exact signed distance.
119
- - `toolwake --version` (also `-V` and `-v`). The CLI had no way to report its
120
- own version: `toolwake -v` failed with "the following arguments are
121
- required: source", which reads as a usage mistake rather than a missing
122
- feature.
123
-
124
- ## [0.1.1] — 2026-09-17
125
-
126
- Performance only. Every report is byte-identical to 0.1.0 — verified on three
127
- real toolpaths — because neither change touches what is computed, only how
128
- much work is done to compute it.
129
-
130
- ### Fixed
131
- - `Deposit._candidates` walked every grid cell in the query's bounding box.
132
- The tool's box includes the luer housing, 130 mm across, while the grid is
133
- sized for a 45 um bead, so each query swept roughly 5 000 mostly-empty cells:
134
- 43.8 million dict lookups over one 1 747-row toolpath, and 86% of total
135
- runtime. It now enumerates whichever is smaller, the box's cells or the cells
136
- that actually hold material. Same set returned, so this is purely a cost
137
- choice.
138
- - `Deposit` stored segments in Python lists and indexed them with
139
- `np.asarray(self._a)[cand]`, rebuilding an array of the entire wake on every
140
- query. Cost therefore tracked total deposit size rather than candidate
141
- count — quadratic over a sweep, and invisible behind a broad phase that was
142
- doing its job. Storage is now capacity-doubling arrays, so a query costs
143
- O(candidates). With candidates pinned at 2, a query went from 12.5 ms to
144
- 0.57 ms at 16 000 segments.
145
-
146
- Measured end to end, unchanged results:
147
-
148
- | toolpath | rows | 0.1.0 | 0.1.1 |
149
- |---|---|---|---|
150
- | LightPipeRobotTest | 1 170 | 7.29 s | 0.42 s |
151
- | small_slab | 1 747 | 16.80 s | 2.22 s |
152
- | test_infill | 2 674 | 29.42 s | 6.72 s |
153
-
154
- ### Added
155
- - `Deposit.last_probe` — cells inspected by the most recent query, so the cost
156
- invariant can be asserted without timing anything. Two regression tests use
157
- it; both were confirmed to fail against 0.1.0.
158
-
159
- ## [0.1.0] — 2026-09-14
160
-
161
- First release.
162
-
163
- ### Added
164
- - `Toolpath` — load from G-code (`M82`/`M83` aware, so print and travel moves
165
- are told apart correctly) or from `(N, 6)` pose files; `helix` and
166
- `conical_helix` fixtures.
167
- - `Needle` / `ToolProfile` — tools as a coaxial stack of sections, the way CAM
168
- describes one. `Needle.luer()` models a luer-lock dispensing tip whose hub is
169
- roughly 50x the cannula diameter.
170
- - `Deposit` — accumulating wake with a spatial hash for broad phase and exact
171
- capsule/box distance for narrow phase, plus a trailing-window rule so the
172
- tool never collides with the bead it is currently extruding.
173
- - `simulate` — per-row clearance against everything laid earlier, naming which
174
- section of the tool was closest.
175
- - `animate` — mp4/gif of the tool and its wake (needs matplotlib).
176
- - `to_html` / `to_html_str` — a self-contained interactive viewer with no
177
- external requests; step between collisions, deep-link any frame.
178
- - `ToolwakeSession` / `asgi_routes` — serve the viewer for embedding in another
179
- GUI, with a version poll so an iframe follows new results.
180
- - `toolwake` CLI; exits 2 on a collision so it drops into a pre-flight gate.
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. Format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.5.0] — 2026-11-22
8
+
9
+ Correctness. Reported clearances change — they can only go DOWN, towards the
10
+ truth: compared row by row against 0.4.0 on six synthetic paths and four real
11
+ G-code files, no row reports more clearance than before, and no penetration
12
+ count changed. Slower: see below.
13
+
14
+ ### Fixed
15
+ - **A needle in the middle of a long bead was not seen.** Each bead was
16
+ measured at its two ends and its midpoint, and filed in the grid only
17
+ there. A cannula pushed into a 10 mm bead 2.5 mm from one end — its wall
18
+ straddling the bead — reported clear (`inf`); the true clearance is
19
+ -0.070 mm. Beads are now filed along their whole length, and the narrow
20
+ phase finds the closest point anywhere along each one: branch and bound
21
+ on the distance field, using its Lipschitz bound and, where the shape
22
+ provides one, a convex lower bound that settles flat and smooth minima in
23
+ a step or two. The result is a distance measured to a real point, never
24
+ below the truth and within 1 nm of it.
25
+
26
+ What it found that 0.4.0 missed, worst clearance per file: a non-planar
27
+ two-wall path -2.28 -> -4.19 mm (hub, same 243 rows penetrating);
28
+ `test_infill` +0.024 -> 0.000 mm; `LightPipeRobotTest` 0.022 -> 0.005 mm.
29
+ One test fixture had been hiding a real collision: a 13 mm diagonal laid
30
+ between two layers, which the second layer's nozzle cuts into by 9.9 um.
31
+ - **A solid tool section treated its own axis as a surface.** For a section
32
+ with no bore (taper, hub, collar), depth inside it was measured to the
33
+ nearer of the wall and the AXIS, so a point on the axis deep inside the hub
34
+ read as touching (0) rather than 4.5 mm in.
35
+
36
+ ### Changed
37
+ - `Capsule`, `Cylinder` and `Box` gain `_probe` (distance, a convex lower
38
+ bound on it, and the bound's gradient), and `Cylinder` gains `_hints`. A
39
+ shape with only `distance` still works, with the Lipschitz bound alone.
40
+ - **With two grids, beads longer than eight fine cells are filed in the
41
+ coarse grid only**, and fine queries look them up there too. Filed along
42
+ their length at needle-sized cells, a 240 mm tray's infill put 1.5 million
43
+ cells in the fine grid in its first 20 000 rows; now 25 000.
44
+ - **Slower, measured back to back against 0.4.0** (best of three; this
45
+ laptop's timings move +-30% between runs): 1.7-2.3x on the 36 305-row
46
+ SMOL part, 2.5-3.0x on the small slabs, 1.8x on LightPipe, 3.2x on the
47
+ first 60 000 rows of the 240 mm tray, whose long infill lines make the
48
+ most candidates. Still linear in row count, and still ahead of 0.3.0. The
49
+ cost is real work: whole beads are filed and measured where three points
50
+ were.
51
+
52
+ ## [0.4.0] — 2026-11-20
53
+
54
+ Performance. Every row's clearance, the culprit part and the verdict are
55
+ unchanged on every file tested — compared row by row against 0.3.0 on six
56
+ synthetic paths (two non-planar) and all five real G-code files.
57
+
58
+ ### Changed
59
+ - **Each row searches a small radius first.** Rows are searched at half a
60
+ fine cell (0.19 mm for a 34G tip), widening x4 towards `search` only when
61
+ nothing is that close. A nozzle laying a layer sits on the one beneath it,
62
+ so most rows stop at the first radius. Searching all of `search` on every
63
+ row cost time in proportion to the material already laid, which made a
64
+ small, dense part quadratic in its row count. Measured back to back against
65
+ 0.3.0: 6.9–7.1x faster on a 36 305-row, 11 mm part; 5.9x on the first
66
+ 60 000 rows of a 240 mm tray.
67
+ - **Two grids.** A fine one sized to the needle tip for the common query, and
68
+ the old tool-sized one for the hub, collar and housing. One grid sized for
69
+ either made the other pay: fine cells left hub queries scanning every
70
+ occupied cell, coarse cells handed the needle every bead in a 5 mm cube.
71
+ - **Queries that miss everything laid so far skip the grid.** On a planar
72
+ print that is the hub, collar and housing on every row.
73
+ - **Beads are filed by the points the narrow phase measures** — ends and
74
+ midpoint — not by their whole bounding box, which for a long diagonal
75
+ infill line was quadratic in its length.
76
+
77
+ ### Fixed
78
+ - **A clearance beyond `search` is now always `inf`**, as 0.3.0 documented.
79
+ It sometimes reported a finite number instead, whenever a coarse grid cell
80
+ happened to reach a bead past `search`: 1 942 of 36 305 rows on one part.
81
+
82
+ ## [0.3.0] — 2026-09-24
83
+
84
+ Performance. Verdicts are unchanged on every file tested; reported clearances
85
+ for DISTANT material are not, which is why this is a minor rather than a patch.
86
+
87
+ ### Changed
88
+ - **`search` default 0.02 → 0.002 m.** Twenty millimetres of padding around
89
+ every query meant that on a 10 mm part the query box covered the whole
90
+ thing and the spatial hash could prune nothing: 949 candidate beads per
91
+ query against a wake of 2 046, and 99.2% of the 30 million point-distance
92
+ evaluations were against material nowhere near the tool.
93
+
94
+ Detection is unaffected — 2 mm is still more than forty times the largest
95
+ bead radius. What changes is that a clearance larger than `search` now
96
+ reports `inf` instead of a number, so anything printing at a much larger
97
+ scale wants this raised.
98
+ - **Grid cell size now follows the TOOL, not `search`.** They were tied
99
+ (`cell = search / 4`), which welded two opposing costs to one knob:
100
+ shrinking `search` cut candidates per query 36x (949 → 26) but grew the
101
+ cells walked per query 1000x (8 → 7 913), because the cell shrank with it.
102
+ Below about 5 mm the second swamped the first and asking for a tighter
103
+ search radius made the whole sweep *slower*.
104
+
105
+ Query boxes are a tool bounding box plus `search`, so the tool's own width
106
+ is what the grid should be sized against. For a luer tip that is the 11 mm
107
+ collar, giving 2.75 mm cells — within noise of the 2.5 mm that measured
108
+ fastest. The housing is excluded: at 130 mm it would force cells so coarse
109
+ that every needle query returned the whole wake.
110
+
111
+ Measured over the reference set, with every verdict and every worst clearance
112
+ identical to 0.2.3:
113
+
114
+ | toolpath | rows | 0.2.3 | 0.3.0 | |
115
+ |---|---|---|---|---|
116
+ | 360-180 SMOL Middle | 36 305 | 626 s | 252 s | 2.5x |
117
+ | 360-180 SMOL Middle (1) | 36 305 | 577 s | 261 s | 2.2x |
118
+ | test_infill | 2 674 | 7.3 s | 1.0 s | 7.2x |
119
+ | REDO WOW Slab | 2 674 | 7.8 s | 3.6 s | 2.2x |
120
+ | slab_infill | 2 674 | 7.2 s | 3.8 s | 1.9x |
121
+ | small_slab | 1 747 | 3.0 s | 2.3 s | 1.3x |
122
+ | LightPipeRobotTest | 1 170 | 0.8 s | 0.7 s | 1.1x |
123
+
124
+ Timings are from one laptop and vary with what else it is doing; treat the
125
+ ratios as indicative, not as a benchmark.
126
+
127
+ ## [0.2.3] — 2026-09-18
128
+
129
+ Touching is not penetrating. Reported collision counts change.
130
+
131
+ ### Fixed
132
+ - **Exact tangency was reported as a collision, at random.** With
133
+ `bead_radius` and `bead_drop` both h/2 — the setting that makes a bead fill
134
+ its layer, which 0.2.1 introduced — a same-layer neighbour passing under the
135
+ nozzle wall sits at a clearance of EXACTLY zero. Which side of zero each one
136
+ lands on is rounding, not geometry.
137
+
138
+ On a real 36 305-row part that put **4 677 rows, 12.9% of the file**, on the
139
+ wrong side and reported them as collisions. Every one was blamed on the
140
+ cannula, every culprit bead was a same-layer neighbour 0.066–0.093 mm away
141
+ laterally — under the wall, outside the bore — and every penetration depth
142
+ printed as `-0.0000 mm`.
143
+
144
+ `Result.n_hits` and `Result.status` now ignore anything shallower than
145
+ `CONTACT_TOL` (1e-12 m), which is six orders of magnitude above
146
+ double-precision noise on metre-scale coordinates and seven below anything
147
+ this models. `report()` reports such a row as `0.0` rather than `-0.0`.
148
+ - **A zero threshold reported tangencies as "close".** With no warning band,
149
+ a clearance of -1e-13 satisfied both "not penetrating" and "below the
150
+ threshold", so a clean result came back as `warn`. A threshold of zero now
151
+ means what it says: only penetration counts.
152
+
153
+ ## [0.2.2] — 2026-09-18
154
+
155
+ Bounds the size of the viewer page. No reported number changes.
156
+
157
+ ### Fixed
158
+ - **The viewer inlined every deposited bead, so the page grew without limit.**
159
+ Frames were capped at 400; beads were not capped at all. A 2 674-row path
160
+ already produces a 1.2 MB page, and a 100 000-row one would produce tens of
161
+ megabytes — which is a problem the moment anyone raises their row budget and
162
+ tries to embed the result in an iframe.
163
+
164
+ `to_html_str` now takes `max_beads` (default 20 000) and decimates the drawn
165
+ wake on the same rule as frames: sample evenly, and never drop a bead
166
+ something collided with. Purely cosmetic — the report is computed from the
167
+ full deposit, and nothing on the page claims a bead count.
168
+
169
+ ## [0.2.1] — 2026-09-18
170
+
171
+ Finishes 0.2.0. That release fixed the tool's geometry; this one fixes the
172
+ material's. Reported clearances change again.
173
+
174
+ ### Fixed
175
+ - **The bead was round at the bore diameter, so it was taller than its own
176
+ layer.** A bead laid at layer height h is squashed to h and spreads
177
+ sideways; kept round it pokes up through where the nozzle will sit on the
178
+ next pass. On a 0.036 mm-layer slab with a 0.09 mm bore that was 498 rows
179
+ reported, 391 of them blamed on material exactly one layer below.
180
+ - **The bead was centred on the toolpath, i.e. in the nozzle TIP's own plane.**
181
+ Material leaving the bore fills the gap between the previous layer's top and
182
+ the nozzle face, occupying [z - h, z] — its centre is h/2 down. Straddling
183
+ the face's plane, any same-layer neighbour passing under the wall reported a
184
+ collision of exactly one bead radius: tangent contacts dressed up as
185
+ penetrations. 41 rows on the same slab, every one at exactly -bead_radius,
186
+ which is what gave it away.
187
+
188
+ Rows reported as penetrating, across both releases:
189
+
190
+ | toolpath | 0.1.1 | 0.2.0 | 0.2.1 |
191
+ |---|---|---|---|
192
+ | LightPipeRobotTest | 7 | 0 | **0** |
193
+ | test_infill | 2 193 | 0 | **0** |
194
+ | small_slab | 1 224 | 498 | **0** |
195
+
196
+ Every G-code file in the reference set now reports clear.
197
+
198
+ ### Added
199
+ - `simulate(bead_radius=..., bead_drop=...)` — the laid bead's size, and where
200
+ it sits relative to the nozzle face. `bead_drop` is applied along the TOOL
201
+ axis, not -Z, so it stays correct on a non-planar move. Explicit arguments
202
+ rather than inferred from the path: only the caller knows whether a Z step
203
+ is a layer or a ramp.
204
+
205
+ ## [0.2.0] — 2026-09-18
206
+
207
+ Reported clearances change. The TOOL was modelled with two pieces of geometry
208
+ it does not have, and both made it collide with the print it was making. The
209
+ BEAD had two of its own; those are 0.2.1.
210
+
211
+ ### Fixed
212
+ - **Tool sections were capsules, so the tool reached below its own tip.** A
213
+ capsule's hemispherical cap bulges a full radius past its endpoint, so a
214
+ 0.095 mm-radius cannula occupied 0.095 mm of space beneath the nozzle — and
215
+ the space beneath the nozzle is the part. On a 0.06 mm-layer print that
216
+ swallowed the two layers underneath on nearly every row: 2 193 of 2 674 rows
217
+ reported as collisions, worst -0.14 mm, every one blamed on the cannula
218
+ (2 177 of them by material *below* the tip). Sections are now flat-ended
219
+ `Cylinder`s. Beads stay capsules: extruded material does have rounded ends.
220
+ - **The cannula was modelled solid, so the bore counted as an obstacle.** A
221
+ needle is a tube. Material under an open bore — the bead being laid, and the
222
+ layer being laid onto — is in the hole, not against the wall. `Section` now
223
+ takes `r_inner` and `Cylinder` an `inner_radius`. `blunt_cannula` already
224
+ accepted `inner_d` and silently discarded it, which is how the bore went
225
+ missing.
226
+
227
+ On the three reference toolpaths, rows reported as penetrating:
228
+
229
+ | toolpath | 0.1.1 | flat tip | + open bore |
230
+ |---|---|---|---|
231
+ | LightPipeRobotTest | 7 | 2 | **0** |
232
+ | test_infill | 2 193 | 16 | **0** |
233
+ | small_slab | 1 224 | 1 218 | 498 |
234
+
235
+ `small_slab`'s remaining 498 are the bead model, not the tool; fixed in 0.2.1.
236
+
237
+ ### Added
238
+ - `Cylinder` — flat-ended, optionally hollow, exact signed distance.
239
+ - `toolwake --version` (also `-V` and `-v`). The CLI had no way to report its
240
+ own version: `toolwake -v` failed with "the following arguments are
241
+ required: source", which reads as a usage mistake rather than a missing
242
+ feature.
243
+
244
+ ## [0.1.1] — 2026-09-17
245
+
246
+ Performance only. Every report is byte-identical to 0.1.0 — verified on three
247
+ real toolpaths — because neither change touches what is computed, only how
248
+ much work is done to compute it.
249
+
250
+ ### Fixed
251
+ - `Deposit._candidates` walked every grid cell in the query's bounding box.
252
+ The tool's box includes the luer housing, 130 mm across, while the grid is
253
+ sized for a 45 um bead, so each query swept roughly 5 000 mostly-empty cells:
254
+ 43.8 million dict lookups over one 1 747-row toolpath, and 86% of total
255
+ runtime. It now enumerates whichever is smaller, the box's cells or the cells
256
+ that actually hold material. Same set returned, so this is purely a cost
257
+ choice.
258
+ - `Deposit` stored segments in Python lists and indexed them with
259
+ `np.asarray(self._a)[cand]`, rebuilding an array of the entire wake on every
260
+ query. Cost therefore tracked total deposit size rather than candidate
261
+ count — quadratic over a sweep, and invisible behind a broad phase that was
262
+ doing its job. Storage is now capacity-doubling arrays, so a query costs
263
+ O(candidates). With candidates pinned at 2, a query went from 12.5 ms to
264
+ 0.57 ms at 16 000 segments.
265
+
266
+ Measured end to end, unchanged results:
267
+
268
+ | toolpath | rows | 0.1.0 | 0.1.1 |
269
+ |---|---|---|---|
270
+ | LightPipeRobotTest | 1 170 | 7.29 s | 0.42 s |
271
+ | small_slab | 1 747 | 16.80 s | 2.22 s |
272
+ | test_infill | 2 674 | 29.42 s | 6.72 s |
273
+
274
+ ### Added
275
+ - `Deposit.last_probe` — cells inspected by the most recent query, so the cost
276
+ invariant can be asserted without timing anything. Two regression tests use
277
+ it; both were confirmed to fail against 0.1.0.
278
+
279
+ ## [0.1.0] — 2026-09-14
280
+
281
+ First release.
282
+
283
+ ### Added
284
+ - `Toolpath` — load from G-code (`M82`/`M83` aware, so print and travel moves
285
+ are told apart correctly) or from `(N, 6)` pose files; `helix` and
286
+ `conical_helix` fixtures.
287
+ - `Needle` / `ToolProfile` — tools as a coaxial stack of sections, the way CAM
288
+ describes one. `Needle.luer()` models a luer-lock dispensing tip whose hub is
289
+ roughly 50x the cannula diameter.
290
+ - `Deposit` — accumulating wake with a spatial hash for broad phase and exact
291
+ capsule/box distance for narrow phase, plus a trailing-window rule so the
292
+ tool never collides with the bead it is currently extruding.
293
+ - `simulate` — per-row clearance against everything laid earlier, naming which
294
+ section of the tool was closest.
295
+ - `animate` — mp4/gif of the tool and its wake (needs matplotlib).
296
+ - `to_html` / `to_html_str` — a self-contained interactive viewer with no
297
+ external requests; step between collisions, deep-link any frame.
298
+ - `ToolwakeSession` / `asgi_routes` — serve the viewer for embedding in another
299
+ GUI, with a version poll so an iframe follows new results.
300
+ - `toolwake` CLI; exits 2 on a collision so it drops into a pre-flight gate.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolwake
3
- Version: 0.2.3
3
+ Version: 0.5.0
4
4
  Summary: Simulate a depositing tool travelling a toolpath, accumulate the material it leaves in its wake, and check the tool against it.
5
5
  Author-email: Zane Bates <zanetbates1@gmail.com>
6
6
  License: MIT
@@ -124,11 +124,24 @@ false collision. `Toolpath.from_gcode` handles both `M82` and `M83`, because
124
124
  whether a row extrudes depends on it and slicers disagree — Cura emits `M82`,
125
125
  PrusaSlicer `M83`.
126
126
 
127
- **Two-phase queries.** A uniform spatial hash narrows the candidate beads, then
128
- exact capsule/box distance measures against those only. A plain occupancy grid
129
- would give a binary answer quantised to the voxel size; this reports a real
130
- distance. The grid is sized to the *query* radius rather than the bead — getting
131
- that wrong made an early version 16x slower for identical results.
127
+ **Two-phase queries.** A spatial hash narrows the candidate beads, then the
128
+ narrow phase finds the closest point along each of those, by branch and bound
129
+ on the distance field: the reported clearance is a distance actually measured
130
+ to a point on a bead, never below the true one and within a nanometre of it.
131
+ A plain occupancy grid would give a binary answer quantised to the voxel size;
132
+ this reports a real distance. There are two grids, one sized to the needle tip
133
+ and one to the hub, because a single grid suits one of those queries and taxes
134
+ the other.
135
+
136
+ Measuring a bead only at its ends and middle — as 0.4.0 and earlier did — is
137
+ blind to everything between: a needle pushed into a 10 mm bead 2.5 mm from one
138
+ end reported clear.
139
+
140
+ **Small radius first.** Each row is searched at a fraction of a millimetre and
141
+ only widens towards `search` if nothing is that close. A nozzle laying a layer
142
+ sits on the one beneath it, so most rows are answered from a handful of beads.
143
+ Searching the full radius on every row cost time in proportion to everything
144
+ printed so far, which made a small, dense part quadratic in its row count.
132
145
 
133
146
  ## Embedding in another GUI
134
147