Skip to content

Feat/vector cleanup - #532

Merged
knipknap merged 10 commits into
barebaric:mainfrom
switch87:feat/vector-cleanup
Oct 11, 2026
Merged

knipknap merged 10 commits into
barebaric:mainfrom
switch87:feat/vector-cleanup

Conversation

@switch87

@switch87 switch87 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Path clean-up tools in the Object menu and canvas context menu:
Close Paths and Join Open Paths with a tolerance in mm, Delete
Duplicates (duplicate contours inside a workpiece and stacked copies
of whole workpieces), and Break Apart (one workpiece per contour,
holes and open paths included). Each is a single undo step (#516 )

@knipknap knipknap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this PR! In general the approach looks good to me - I just think the geometry manipulation core logic should move into Raygeo. This affects just one file - the rest looks fine to me!

I did not perform a manual test yet.

Comment thread rayforge/core/path_cleanup.py Outdated
Close open contours whose ends meet within a tolerance, join open
contours into longer paths (reversing pieces where needed), remove
duplicate contours and stacked duplicate workpieces, and break a
workpiece apart into one workpiece per contour.

The geometry work lives in rayforge.core.path_cleanup and runs in
millimetres, so tolerances do not depend on the workpiece scale. Gaps
are bridged with straight segments between existing end points, so the
bounding box and placement stay the same. Each command writes the
result through ChangePropertyCommand on _edited_boundaries and is a
single undo step. Break Apart reuses SplitCmd with a new
ContourSplitStrategy that, unlike the connectivity split, keeps holes
and open paths as pieces of their own.

Refs barebaric#516
Add Break Apart, Close Paths…, Join Open Paths… and Delete Duplicates
to the Object menu and a Clean Up Paths submenu to the canvas context
menu. Close and join ask for a tolerance in a small dialog that
remembers the last value per tool for the session; each tool reports
its result in a toast.

Includes translations for all shipped languages, a documentation page
in every website language and a changelog entry.

Closes barebaric#516
Comparing every pair of contours with a similar length made Delete
Duplicates take seconds on files with thousands of short, equally long
segments (a 3,600-segment line soup took 9 s). Kept contours are now
indexed by the lower-left corner of their bounding box, so only
neighbouring candidates are compared (0.03 s for the same file).

Refs barebaric#516
The geometry manipulation core moves into raygeo (barebaric/raygeo#56)
as suggested in review: the editor command now calls the Geometry
methods close_open_contours, join_open_contours, remove_duplicate_contours,
matches and split_drawn_contours, and the core module with its unit
tests moves there. The command, undo integration and UI stay here.

Needs a raygeo release that contains barebaric/raygeo#56.
@switch87

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Done — the geometry manipulation core now lives in Raygeo: barebaric/raygeo#56 adds close_open_contours, join_open_contours, remove_duplicate_contours, matches and split_drawn_contours to the Raygeo Geometry class, with the unit tests moved along.

This PR keeps only the editor command (undo integration, millimetre scaling, duplicate-workpiece detection) and the UI, and calls the new methods. Once raygeo is released with those methods and the pin is bumped here, CI should go green — same situation as #541.

@switch87

Copy link
Copy Markdown
Contributor Author

Requested change is in: rayforge/core/path_cleanup.py is gone. The geometry manipulation now lives in raygeo (Geometry.close_open_contours / join_open_contours / remove_duplicate_contours / matches / split_drawn_contours, barebaric/raygeo#56) and rayforge keeps only the editor command (rayforge/doceditor/path_cleanup_cmd.py) and the UI.

Also merged main in 8e3e0cf to clear the CHANGELOG.md conflict (both sides added a bullet under UNRELEASED > Added; kept them in issue order, #514 then #516).

Targeted tests green locally: tests/doceditor/test_path_cleanup_cmd.py 11 passed, tests/ui_gtk/doceditor/test_path_tolerance_dialog.py 3 passed, ruff clean on all changed files.

One blocker remains before this can go green, and it is not in this PR: requirements.txt pins raygeo==1.62.0, but the new methods are not in any released raygeo yet — they only exist on feat/path-cleanup. So from raygeo.geo import Geometry plus Geometry.close_open_contours cannot resolve in CI until raygeo#56 is merged and released, after which the pin needs bumping here (requirements.txt and pixi.toml). The same applies to #541, which is waiting on raygeo#54.

@knipknap

Copy link
Copy Markdown
Contributor

"One blocker remains before this can go green, and it is not in this PR: requirements.txt pins raygeo==1.62.0, but the new methods are not in any released raygeo yet"

Actually, 1.62.0 is online since yesterday :-)

raygeo 1.63.0 ships the path clean-up operations this PR calls
(close_open_contours, join_open_contours, remove_duplicate_contours,
matches, split_drawn_contours; raygeo#56), so the pins can move off
1.62.0, which predates them.
@knipknap

Copy link
Copy Markdown
Contributor

Correction to my last comment: I thought 1.62.0 included the new methods, but it was cut a few hours before raygeo#56 was merged, so it did not. I have released raygeo 1.63.0 now — it contains the path clean-up operations (raygeo#56) and the travel optimizer's best start point / prefer corners (raygeo#54, which also unblocks #541).

Bumped the pins to 1.63.0 in 8ca6a0a (requirements.txt, debian/requirements-bundle.txt, pixi.toml, pixi.lock). Verified against the released wheel: the 14 targeted tests pass, and the full backend suite passes (7282 passed).

The Close/Join Paths dialog rendered at Adw.AlertDialog's default
content width of 300 px, which wrapped the spin row's title mid-word
and stacked the response buttons. Give the preferences group a minimum
width so the title and buttons fit.
Captures the Close Paths dialog over a selected vector workpiece for
the path clean-up documentation.
Use relative file paths ending in .md for the internal links in the
path clean-up docs and the canvas-tools cross-reference, matching the
convention from 8043b65 (.md-less links broke client-side
navigation), in English and all translations. Each language's page
also embeds the new screenshot.
@knipknap
knipknap merged commit fc2b8fb into barebaric:main Oct 11, 2026
32 checks passed
@knipknap

Copy link
Copy Markdown
Contributor

I added some minor corrections and a screenshot, and bumped to Raygeo 1.63.0. Thanks for the feature!

@switch87
switch87 deleted the feat/vector-cleanup branch October 12, 2026 18:58

This branch was successfully deployed

1 active deployment
pypi — 28809f76 Deployed Oct 11, 2026 by knipknap via Build and Publish Wheel #2226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants