Skip to content

fast_winding_number: point-cloud and pre-built tree support (#292) - #307

Merged
alecjacobson merged 3 commits into
mainfrom
fast-winding-number-points-and-bvh
Aug 11, 2026
Merged

fast_winding_number: point-cloud and pre-built tree support (#292)#307
alecjacobson merged 3 commits into
mainfrom
fast-winding-number-points-and-bvh

Conversation

@alecjacobson

Copy link
Copy Markdown
Contributor

Closes #292.

The binding only exposed the (V, F, Q) triangle-soup one-shot. This adds the
rest of libigl's fast_winding_number API so point clouds and reusable
acceleration structures
are supported (enabling full signed-distance workflows
and multiple query sets against one build).

New API

Point-cloud one-shot

W = igl.fast_winding_number(P, N, A, Q, expansion_order=2, beta=2.0)

Reusable triangle-soup BVH — build once, query many times:

bvh = igl.FastWindingNumberBVH()
bvh.init(V, F, order=2)
W1 = bvh.winding_number(Q1)
W2 = bvh.winding_number(Q2)   # no rebuild

Point-cloud octree precompute — reuse the Taylor expansion across query sets
(builds on the already-bound igl.octree):

point_indices, CH, CN, _ = igl.octree(P)
CM, R, EC = igl.fast_winding_number_precompute(P, N, A, point_indices, CH, 2)
W = igl.fast_winding_number(P, N, A, point_indices, CH, CM, R, EC, Q, beta=2.0)

The original igl.fast_winding_number(V, F, Q) is unchanged.

Testing

test_fast_winding_number exercises all four paths on a unit-sphere point
set/mesh: interior queries → ~1, exterior → ~0, and the BVH and cached-octree
results match their one-shot equivalents. Full suite: 92 passed locally.

🤖 Generated with Claude Code

The binding previously only supported the (V,F,Q) triangle-soup one-shot. This
adds the rest of libigl's fast_winding_number API so point clouds and reusable
acceleration structures are available:

- Point-cloud one-shot: fast_winding_number(P, N, A, Q, expansion_order=2,
  beta=2.0).
- Reusable triangle-soup BVH: FastWindingNumberBVH class with init(V, F, order)
  and winding_number(Q, accuracy_scale) so many query sets reuse one build.
- Point-cloud octree precompute: fast_winding_number_precompute(P, N, A,
  point_indices, CH, order) -> (CM, R, EC), plus a cached-evaluation overload
  fast_winding_number(P, N, A, point_indices, CH, CM, R, EC, Q, beta). Build the
  octree with the existing igl.octree(P).

Adds test_fast_winding_number covering all four paths on a unit-sphere point
set / mesh (inside ~1, outside ~0; cached paths match the one-shots). Full
suite: 92 passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alecjacobson

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com>

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Done — merged origin/main into the branch and resolved the conflict in tests/test_all.py by keeping both test_fast_winding_number (from this PR) and test_vertex_components_from_adjacency_matrix (from main). Commit: 1c1085f.

@alecjacobson

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…d test_ambient_occlusion

Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com>

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved — merged the latest origin/main and kept both test_fast_winding_number (from this PR) and test_ambient_occlusion (new in main). Commit: 413cc37.

@alecjacobson
alecjacobson merged commit 0a57982 into main Aug 11, 2026
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.

fast_winding_number bindings do not support pre-built BVHs/octrees

2 participants