Allow skipping SimplifyResult in boolean operations - #273
Open
PawelPisarek wants to merge 1 commit into
Open
PawelPisarek wants to merge 1 commit into
PawelPisarek wants to merge 1 commit into
Conversation
Booleans end with an unconditional newBody.SimplifyResult(true, true, 1e-3). On some shapes that step turns a valid solid into an invalid one, and the damage is silent: a later boolean on it returns an empty result while reporting HasErrors() === false and IsDone() === true. This adds a simplify option (default true, so behaviour is unchanged) to fuse, cut and intersect, so callers hitting the problem have a way out. Measured on the affected shapes: skipping the step keeps the volume identical, makes every solid valid, and is 9-16% faster; the face count grows by 4-5% on curved shapes. Verifying the result instead and falling back was measured too, but it costs 7-22% on every boolean for every user, so it is not offered as a default here.
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.
Fixes #272.
Booleans end with an unconditional
newBody.SimplifyResult(true, true, 1e-3). On some shapes that step turns a valid solid into an invalid one, and the damage is silent — a later boolean on it returns an empty result while reportingHasErrors() === falseandIsDone() === true. #272 has a self-contained reproduction.This adds a
simplifyoption tofuse,cutandintersect. It defaults totrue, so nothing changes for existing callers; it only gives people hitting the problem a way out.Measurements
Taken on the affected shapes (a lofted picture-frame moulding, 23 shape/size combinations):
Why not verify and fall back instead
Checking the simplified result and reverting when it is invalid would fix everyone without an API change, so I measured it.
BRepCheck_Analyzercosts 16–38 % of the boolean itself (29 ms against a 77 ms union; 269 ms against 1626 ms; 367 ms against 2341 ms), which makes the safe variant 7–22 % more expensive on every boolean for every user — to rescue a minority of shapes.That trade-off felt like yours to make rather than mine, so this PR takes the cheap route. Happy to switch to the verify-and-fall-back version, or to make it a third mode (
simplify: "safe"), if you prefer.Checks
tsc --noEmitcleanvitest runinpackages/replicad: 53 passed (49 existing + 4 new in__tests__/boolean-simplify.test.ts)