Skip to content

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

Open
alecjacobson wants to merge 1 commit into
mainfrom
fast-winding-number-points-and-bvh
Open

fast_winding_number: point-cloud and pre-built tree support (#292)#307
alecjacobson wants to merge 1 commit 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>
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

1 participant