Show primitive mapping in the Mesh Boolean examples - #6817
Merged
Merged
Conversation
All five Mesh Boolean examples now pass a BooleanResultMapper to the operation and use it to report which faces of the result came from each input mesh and which ones the cut created.
Every Mesh Boolean example now maps one particular face of the first input mesh to the faces of the result it produced, and maps a face of the result back to the face it came from via getNew2OldFaceMap. getNew2OldFaceMap sized its output as the largest new face id instead of that id plus one, so it wrote one element past the end of the vector and never returned the entry for the last mapped face.
Grantim
approved these changes
Sep 9, 2026
4 tasks
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.
Nothing in the examples demonstrated
BooleanResultMapper— the way to relate faces, vertices and edges of the input meshes to the primitives of the boolean result.All five language variants (C++, C, Python, C#, JavaScript) now pass a mapper to the operation and use it to report:
mapover the inputs' valid faces,newFaces);getNew2OldFaceMap.For the two spheres in the examples that prints:
Fix in
getNew2OldFaceMapWriting the reverse example surfaced an off-by-one: the map was sized
maxNewFace(the largest new face id) rather thanmaxNewFace + 1, sooutMap[nf] = offor that largest id wrote one element past the end of the vector — an assert in a Debug build, an out-of-bounds write in Release — and the returned map never contained the entry for the last mapped face. For the spheres above, the last face of the result coming fromAis 8863 while the map's size was 8863; it is now 8864 and that face resolves to its origin, 7199.No test asserted on the size of the returned map, so nothing else changes.
Docs
doxygen/examples/MeshBoolean.doxmentions the mapper and the reverse map above the tabs.MR::BooleanResultMapper's doc comment now shows the two new C++ snippets (markers1and2), the same wayMR::booleanshows marker0.Verification
MRMesh(with the fix) and prints the output above; the reverse lookup of the lastAface was checked separately against both the old and the new sizing.meshlibwheel.cl /W3) against the generatedMeshLibC2headers.MRDotNet2Test/src/BooleanTests.cs,MRWasmTest/booleanMapper.test.mjsand the neighbouring examples (FaceBitSet.fromIndices,FaceMap.toArray, theusingdisposal style).CI: ubuntu-x64 (C++ and C examples, MRTest) and windows (C# examples) are enabled; the other platforms are disabled.