Skip to content

Fix Sketcher split edge dropping coincident and dimensional constrain…#28244

Closed
cray98-code wants to merge 2 commits intoFreeCAD:mainfrom
cray98-code:fix-split-edge-constraints
Closed

Fix Sketcher split edge dropping coincident and dimensional constrain…#28244
cray98-code wants to merge 2 commits intoFreeCAD:mainfrom
cray98-code:fix-split-edge-constraints

Conversation

@cray98-code
Copy link
Copy Markdown

Fixes #28240

The Sketcher Split Edge tool drops coincident and dimensional constraints
when splitting a line. Parallel constraints survive correctly. This is a
regression from 1.0.2.

Root cause: In SketchObject::split(), the erase_if filter before calling
deriveConstraintsForPieces() keeps only PointPos::none constraints, silently
discarding anything referencing PointPos::start, PointPos::end, or
PointPos::mid, which includes coincident and dimensional constraints.

Fix: Only exclude InternalAlignment constraints and start/end/mid constraints
(which are handled separately by transferConstraints()). All other constraints
including dimensional ones are correctly passed to deriveConstraintsForPieces()
for remapping.

Tested against 1.1rc2, constraints now survive the split correctly.

Example from 1.1rc2

image image

@github-actions github-actions bot added the Mod: Sketcher Related to the Sketcher Workbench label Mar 10, 2026
@maxwxyz maxwxyz added this to the 1.1 milestone Mar 10, 2026
@maxwxyz maxwxyz moved this from Queue to Merge Meeting in Merge Queue Mar 10, 2026
@maxwxyz maxwxyz added the Type: Bug This issue or PR is related to a bug label Mar 10, 2026
@maxwxyz maxwxyz removed the status in Merge Queue Mar 10, 2026
@maxwxyz maxwxyz requested a review from PaddleStroke March 10, 2026 19:28
@Reqrefusion Reqrefusion moved this to Queue in Merge Queue Mar 11, 2026
@PaddleStroke
Copy link
Copy Markdown
Contributor

@AjinkyaDahale please check, it most likely comes from the refactor so you are best to know if the fix is the correct one. Thanks

@AjinkyaDahale
Copy link
Copy Markdown
Contributor

Unfortunately I'll be mostly unavailable for another week. From a cursory glance, I see that this commit edits split() directly. If there is a reasonable possibility that these constraints can apply when trim and extend are called, even if they do not in 1.0, this functionality should be handled in deriveConstraintsForPieces (I might not have written the name exactly as it is in the code, please confirm). For this, you might need to treat coincidence and distance constrains separately.

Also, as a general note, please try to limit the increase in cognitive complexity.

Finally, some parts of this code (particularly trim, split, join and extend) may be considered a "rewrite" rather than "refactor", so some functionality might have been dropped.

@maxwxyz maxwxyz modified the milestones: 1.1, 1.2 Mar 16, 2026
@kadet1090 kadet1090 requested a review from maxwxyz March 16, 2026 17:33
@kadet1090 kadet1090 added Requires: Testing The PR needs testing by users and developers Type: Regression Bugs describing a regression or PRs fixing one and removed Type: Regression Bugs describing a regression or PRs fixing one labels Mar 16, 2026
Copy link
Copy Markdown
Collaborator

@maxwxyz maxwxyz left a comment

Choose a reason for hiding this comment

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

Tested

@maxwxyz maxwxyz added Approved: Tested The PR was manually tested and approved and removed Requires: Testing The PR needs testing by users and developers labels Mar 16, 2026
@maxwxyz maxwxyz moved this from Queue to Approved in Merge Queue Mar 16, 2026
@maxwxyz maxwxyz requested a review from theo-vt March 23, 2026 17:16
@maxwxyz
Copy link
Copy Markdown
Collaborator

maxwxyz commented Mar 23, 2026

@cray98-code PR has a conflict

@yorikvanhavre
Copy link
Copy Markdown
Member

Waiting for @theo-vt 's review

Copy link
Copy Markdown
Contributor

@theo-vt theo-vt left a comment

Choose a reason for hiding this comment

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

@hyarion I think it's good!

@maxwxyz maxwxyz added the Approved: Code Quality The PR was checked for code quality and approved label Mar 27, 2026
Copy link
Copy Markdown
Contributor

@AjinkyaDahale AjinkyaDahale left a comment

Choose a reason for hiding this comment

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

In addition to thw comments, please confirm if this applies only to split, or if other operations can also benefit from this.

if (con->Type == InternalAlignment) {
return true;
}
if (con->involvesGeoIdAndPosId(GeoId, PointPos::start)) {
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.

This and the next two checks can (should?) be combined into one with || for reducing cognitive complexity.

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.

What was the reason to remove this condition and replace it with three?

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.

Since the array holds only indices involving the geoid and any posid start/end/mid/none, excluding "none" automatically implies the erased indices involve start/mid/end.

So, we can check for internal alignment and NOT none.

The one new thing this covers is if start/mid/end AND none are somehow both involved. Is that the case?

@github-project-automation github-project-automation bot moved this from Approved to Queue in Merge Queue Mar 28, 2026
@maxwxyz
Copy link
Copy Markdown
Collaborator

maxwxyz commented Mar 29, 2026

@cray98-code friendly reminder, PR also has a conflict.

@AjinkyaDahale
Copy link
Copy Markdown
Contributor

AjinkyaDahale commented Mar 29, 2026

Does not seem to work completely. Here, splitting one line keeps the distance, but not the case for the other.
pre-split-28244.zip

@AjinkyaDahale
Copy link
Copy Markdown
Contributor

AjinkyaDahale commented Mar 29, 2026

Tested

@maxwxyz could you please attach a file that works with this PR? The one I attached doesn't work for point on object at all, and only half for the distance constraint.

@luzpaz
Copy link
Copy Markdown
Contributor

luzpaz commented Apr 9, 2026

@maxwxyz could you please attach a file that works with this PR? The one I attached doesn't work for point on object at all, and only half for the distance constraint.

@maxwxyz
Copy link
Copy Markdown
Collaborator

maxwxyz commented Apr 10, 2026

Indeed it does not work with your test file

@maxwxyz maxwxyz added Requested changes: Testing The PR was manually tested and issues were found and removed Approved: Tested The PR was manually tested and approved labels Apr 10, 2026
@cray98-code
Copy link
Copy Markdown
Author

After reviewing the feedback I realise this is beyond my current coding ability to properly address

I don't want to hold up a fix for this bug, so I'm going to close this PR. I hope the description of the root cause and the attempted fix here can be useful as a starting point for someone more experienced to take over.

@github-project-automation github-project-automation bot moved this from Queue to Done in Merge Queue Apr 14, 2026
@cray98-code cray98-code deleted the fix-split-edge-constraints branch April 14, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved: Code Quality The PR was checked for code quality and approved Mod: Sketcher Related to the Sketcher Workbench Requested changes: Testing The PR was manually tested and issues were found Type: Bug This issue or PR is related to a bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Sketcher: Split Edge drops constraints in 1.1rc2/rc3. Regression from 1.0.2

9 participants