Skip to content

geometry: fix point location in meshes over 10,000 elements - #853

Merged
transfix merged 1 commit into
masterfrom
fix/point-location-mesh-box
Oct 28, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/point-location-mesh-box

Conversation

@transfix

@transfix transfix commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

package-macos / libcvc-release-grpc and -grpc-static (and libcvc-release, when it ran) have failed AlgorithmTest.FindTetsContainingPointPerformanceLargeMesh on master since 09fa876, e.g. 40529398170 (jobs 122277740257, 122277741912) and 40486443010. The test name says "Performance", but the failing assertion is total_found > 0: 100 queries found 0 tets. It is a point-location bug.

Root cause

Above 10,000 elements, find_tets_containing_point and find_hexs_containing_point first checked whether the point was inside the mesh's box. They built that box by adding up one bounding_box per vertex. A box around one point has no volume, so its isNull() is true, and operator+= of null boxes stays null. contains() on a null box is false, so the function returned nothing.

The only exception was a point that the per-call CGAL AABB tree saw lying on the boundary surface (do_intersect(Point_3)): it skipped the box test. That skip was the tree's only role, and the tree was rebuilt from extract_surface() on every call.

#808 grew the test's bunny tet mesh from 7,440 tets, on the 1000-10000 path with no mesh-box test, to 289,946. That moved the test onto the broken path. The hex test has been on it all along (64,770 hexes): it found nothing, and passed because it only checked that the mesh had hexes.

Fix

  • For every mesh over 1000 elements, the point is compared with the mesh's box coordinate by coordinate (within_bounds), then only the elements whose own box holds it are tested.
  • The per-call surface extraction and AABB tree are removed, with the CGAL AABB headers and typedefs, which nothing else in algorithm.cpp used.
  • Both performance tests compare their result with testing every element (its own box, then its barycentric or trilinear weights), and require more than 10 of the 100 points to be located. Before, > 0 let the tet bug pass on Windows and Linux.
  • docs/GEOMETRY_API.md and the libigl roadmap row describe the path as it is now. The persistent locator (P2.4) is still planned.

Evidence

Local (Windows, MSVC 14.44 Release, cvcpkg prefix), on the tests' own meshes. "Before" is a build of master with #808 (perf-all tree); "after" is this branch on 9cab98f.

tets: points / hits ms per query hexes: points / hits ms per query
before not printed / 4 691 0 / 0 275
after 25 / 94 17.5 74 / 77 9.7
every element tested 25 / 94 74 / 77

geometry_test --gtest_filter=*Find*Containing*: 3/3 pass. The tet mesh is the solid above the isovalue: for this SDF, the space between the bunny and its box, which the query line crosses at both ends (25 points). The hexes are the voxels inside the bunny (74 points).

CI: the required checks passed. At merge, this branch's run 40616350355 had passed package-linux / libcvc-debug, -release and -release-grpc and all three package-windows lanes; the other lanes were still running. The PR lanes skip the heavy suites, so they don't run this test. The push run of all four fixes together on ci/full/package-lanes, 40615210987, covers package-macos's serial heavy pass, where it runs. That run was still queued at merge.

…oundary

find_tets_containing_point and find_hexs_containing_point, above 10,000
elements, built the mesh's box by adding one bounding_box per vertex. A box
around one point has no volume, so it isNull(), and a sum of null boxes stays
null: the box test then rejected every point. Only a point the per-call AABB
tree saw lying on the boundary surface skipped that test, so a query anywhere
else returned nothing.

#808 grew the bunny tet mesh in FindTetsContainingPointPerformanceLargeMesh
from 7,440 tets to 289,946, which moved it onto this path. The test asserts
only that something was found. Windows found 4 tets and Linux passed too,
but macOS found 0. Testing every tet finds
25 of the 100 points, in 94 tets.

The box is now compared coordinate by coordinate, for any mesh over 1000
elements, and the per-call surface extraction and CGAL AABB tree, which only
fed that test, are gone. Both performance tests now check the result against
testing every element.
@transfix
transfix merged commit 402a64f into master Oct 28, 2026
18 of 24 checks passed
@transfix
transfix deleted the fix/point-location-mesh-box branch October 29, 2026 20:53
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.

1 participant