Skip to content

fix: Fix the problems with float precisions in triangulation process - #112

Merged
Czaki merged 2 commits into
masterfrom
fix_triangulation_precision
Sep 27, 2026
Merged

Czaki merged 2 commits into
masterfrom
fix_triangulation_precision

Conversation

@Czaki

@Czaki Czaki commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Same as napari/bermuda#225

Summary by CodeRabbit

  • Bug Fixes
    • Improved triangulation accuracy for large or closely spaced coordinates, reducing incorrect handling of point orientation and segment intersections.
    • Added coverage for a multi-hole polygon to verify that triangulated area remains accurate with single-precision input.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 221b7681-67d6-463e-9750-52427e925e45

📥 Commits

Reviewing files that changed from the base of the PR and between 37f29a7 and d1573e3.

📒 Files selected for processing (3)
  • src/PartSegCore_compiled_backend/triangulation/intersection.hpp
  • src/tests/data/create_holes_triangulation_failure.txt
  • src/tests/test_triangulate.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Intersection calculations now promote coordinate differences and coefficients to double precision. A regression test triangulates a two-hole polygon loaded as float32 and checks its summed triangle area.

Changes

Triangulation precision

Layer / File(s) Summary
Intersection arithmetic precision
src/PartSegCore_compiled_backend/triangulation/intersection.hpp
Orientation and segment intersection calculations use double-precision intermediates. Segment pairs are ordered consistently before calculation.
Two-hole polygon regression test
src/tests/data/create_holes_triangulation_failure.txt, src/tests/test_triangulate.py
Add a polygon fixture with two holes and a test that triangulates it as float32. The test computes the summed triangle area using float64 coordinates and checks it against 139420612.3.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d1573

No actionable merge-blocking issue was identified. Run the triangulation test as part of normal checks before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing floating-point precision problems in the triangulation process. It is related to the implementation and regression-test changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Czaki
Czaki merged commit 03cf24b into master Sep 27, 2026
20 checks passed
@Czaki
Czaki deleted the fix_triangulation_precision branch September 27, 2026 22:35
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