feat(brep): end-to-end trim-aware torus-face SDF, matched against OCCT#74
feat(brep): end-to-end trim-aware torus-face SDF, matched against OCCT#74
Conversation
Add torus_face_sdf_from_frame (pure JAX, jittable) and torus_face_sdf (convenience wrapper) closing the torus branch of Marschner-style trim-aware SDF built in #73. The composition computes the torus primitive's signed distance sqrt((r - R)^2 + h^2) - minor, applies sign_flip, and feeds the (major-angle u, minor-angle v) UV pair into trim_aware_sdf. Three degenerate cases need the safe-square + double-where guards accumulated on this stack: - polar axis (r == 0): major angle u undefined; - tube-centre ring (r == major AND axial == 0): minor angle v undefined and the primitive distance has a sqrt(0); - torus centre (delta == 0): both angles undefined. 16 unit tests across two fixtures: - sample_torus.step (major=5, minor=1.5) exercises the untrimmed collapse on four off-seam queries, all matching OCCT BRepExtrema_DistShapeShape within 0.15. - A quarter torus built in-test via BRepPrimAPI_MakeTorus(5, 1, pi/2) exercises the phantom regime: query (-5, 0, 0) sits on the tube-centre ring at u=pi (outside the quarter's [0, pi/2]) where the untrimmed primitive classifies it as inside the tube (d_S < 0). The signed blend flips it positive. jax.grad through the query is finite at the torus centre, on the polar axis, on the tube-centre ring, and in the phantom regime. The pure composition JITs end to end. Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 2 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for torus-face signed distance functions (SDF). It adds torus_face_sdf_from_frame and a convenience wrapper torus_face_sdf in src/brepax/brep/trim_frame.py, implementing JAX-compatible logic with guards for degenerate cases to ensure finite gradients. Additionally, a new test suite tests/unit/brep/test_torus_face_sdf.py is included to verify the implementation against OCCT and validate gradient behavior. I have no feedback to provide.
Summary
torus_face_sdf_from_frame(pure JAX, jittable) andtorus_face_sdf(convenience wrapper) closing the torus branch of Marschner-style trim-aware SDF built in feat(brep): extract torus trim-frame data for Marschner composition #73.sign_flipis applied to the torus primitive'ssqrt((r - R)^2 + h^2) - minorand the (major-angle u, minor-angle v) UV pair feedstrim_aware_sdf.r == 0, u undefined), tube-centre ring (r == majorANDaxial == 0, v undefined +sqrt(0)), and torus centre (delta == 0, both angles undefined).sample_torus.step(major 5, minor 1.5) exercises the untrimmed collapse on four off-seam queries, all matching OCCT to 0.15. A quarter torus built in-test viaBRepPrimAPI_MakeTorus(5, 1, pi/2)exercises the phantom regime:(-5, 0, 0)sits on the tube-centre ring atu = pioutside the quarter's[0, pi/2]range; untrimmed primitive would sayd_S < 0(inside tube), the signed blend flips it positive.Verification
uv run pytest697 passed, 1 skipped (matplotlib), 54 deselected (slow)uv run mypy src/0 errorsuv run ruff check src/ tests/cleanuv run ruff format src/ tests/cleanRelated