Repository navigation
Adds Geometry Cleanup to find and fix ends that almost meet - #3603
Merged
Merged
Conversation
GEOMETRYCLEANUPOPEN opens a palette that scans the selected lines, arcs and polylines for three error types: Gap, Overshoot and Undershoot. Each row of the list has the buttons of its repairs: Trim, Extend, Stretch, Move, and Extend to a corner. Each repair is one undo step. While the palette is open, it scans again after each change of the drawing, and after a repair it picks the next row. This is the first part of Geometry Cleanup. The settings dialog, the angle errors, the markers and Keep as designed come later. Co-Authored-By: Claude
Tests the scan of each error type, arcs and polylines, corners, the search grid and the proposed tolerance. Tests each repair and its undo, the objects that are not read, the automatic rescan, and the pick of the next row. Co-Authored-By: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
Adds Geometry Cleanup (GEOMETRYCLEANUPOPEN, GEOMETRYCLEANUPCLOSE), as in AutoCAD 2027: a palette that scans the selected objects for ends that almost meet other geometry and repairs each error the user picks. This first part finds three error types: Gap, Overshoot and Undershoot.
This is the first of several pull requests for Geometry Cleanup. The later ones add the settings dialog (a tolerance for each error type, the proposed tolerance,
.gcsfiles), the Absolute Angle and Relative Angle errors, markers in the drawing with a live preview of a repair, and Keep as designed. They are listed under "Not covered" below.What specifically changed
crates/ocs_geom/src/geom2d/cleanup.rs: the scan. For lines, arcs and polylines it finds:An end that meets other geometry is not an error. An end with more than one candidate is reported once, as the nearest one. A grid keeps the scan from testing every pair of curves.
proposed_tolerancegives 1% of the mean length of the lines and polyline segments, and at least 0.0001.src/modules/manage/geometry_cleanup.rs: the objects the scan reads (lines, arcs and LWPOLYLINEs on the world XY plane, in model space, on layers that are not locked or frozen), the repairs, the Select Objects prompt and the ribbon tool (Manage > Cleanup, beside OVERKILL).src/ui/window/geometry_cleanup.rs: the palette. Select Objects, Rescan, the tolerance, "Remaining Errors" and a foldable list for each error type. Each row has the XY location of the error and, at its end, the buttons of its repairs, each with a tooltip that says what it changes. A click on a row zooms to the error and selects its objects. After a repair, the next row is picked and zoomed to (the row above it at the end of the list), so the user can work down the list.src/app/commands/geometry_cleanup.rs: the commands and the palette's messages. While the palette is open, it scans its objects again after each change of the drawing (an edit, an undo), so the list stays true; not while a command or a grip edit runs, which change the drawing on each move. The picked error stays picked if it is still there.The repairs, each one undo step, after which the palette scans again:
The dock panel, the message, the labels in
src/locale_catalog.rsand in every locale (with the English text).Why
AutoCAD 2027 added Geometry Cleanup. A drawing with ends that almost meet does not hatch, join or offset as the user expects, and the errors are too small to see. OVERKILL removes duplicates and GAPCHECK lists end-to-end gaps, but nothing repaired overshoots, undershoots or gaps.
The help pages name the repairs but not what each one does to the geometry; the rules above are this pull request's reading of them. AutoCAD shows the repairs in a menu on the error and in the drawing; here they are buttons on the error's row until the markers come. With no settings dialog yet, the tolerance is the proposed one, from all the supported objects in model space. A rescan keeps the tolerance that the scan had.
Testing
crates/ocs_geom/src/geom2d/cleanup.rs(23 tests): each error type, ends that meet or are far apart, a short line attached at its other end (not an overshoot), both ends of an arc (counter-clockwise, and clockwise in a polyline) reaching along their circle, an arc that overshoots, a nearly closed polyline, a closed polyline as a target, a polyline's last segment, the corner of an oblique gap and a corner too far away, a large tolerance, a gap across the edge of a search cell, the nearest error winning, the proposed tolerance (with and without arcs), and a tolerance at or below the weld or not finite.src/app/commands/geometry_cleanup_tests.rs(27 tests): the palette opens and closes, and scans the objects selected before it opens; a scan lists one Gap, one Overshoot and one Undershoot; each repair (Trim, Extend, Stretch, Move, Extend at a corner) gives the expected geometry, and Undo takes it back in one step; an arc and a polyline arc end keep their circle; a locked layer, a line off the XY plane, and an arc or polyline with another normal or an elevation are not scanned; a two-point polyline extends; Stretch moves the grip at the repaired end; a repair that the error does not offer changes nothing; a repair after the drawing changed changes nothing; Select Objects scans the selection; picking an error selects its objects; the open palette lists an error again after its repair is undone, scans again after an edit and keeps the picked error, waits for a running command, and a closed palette does not scan; a repair picks the next row, skips a folded type, and a repair that fails keeps the pick; a second fold unfolds a type.cargo test --workspace --locked --no-fail-fast: 8139 passed, 0 failed, 48 ignored (50 new).Not covered
.gcssettings files.Impact to Contributors
A new dock panel (
PanelId::GeometryCleanup) and a new message (Message::GeometryCleanup).🤖 Generated with Claude Code