Implement additive boundary-based polygon splines for non-convex shapes and conforming partitions - #10
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix implementation bugs in piecewise algebraic spline behavior
Implement additive boundary-based polygon splines for non-convex shapes and conforming partitions
Jul 16, 2026
QL-UoHull
marked this pull request as ready for review
July 16, 2026 20:07
Contributor
There was a problem hiding this comment.
Pull request overview
Restores the Li–Tian intended behavior for non-convex polygons and conforming partitions by switching the public polygon evaluator to an additive, boundary-integral-based construction where internal edges cancel under decomposition, eliminating seams and making direct evaluation match decomposition.
Changes:
- Replaces
imp_spline_2d’s arbitrary-polygon path with an oriented-edge additive evaluator; keeps the convex product form asconvex_product_spline_2d. - Adds edge cancellation for decomposition evaluation and introduces partition additive basis fields + partition topology validation.
- Updates demos/tests to use paper-style Section 7 polygons and a conforming Section 9 partition, with regression coverage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_implicit_spline.py | Replaces prior signed-distance/normalized-sum tests with additive construction regressions for Section 7/9. |
| python/implicit_spline/core.py | Implements additive boundary-based imp_spline_2d, edge cancellation for decompositions, additive partition fields, and partition validation utilities. |
| python/implicit_spline/visualization.py | Updates partition surface visualization to plot additive sums (partition_basis_fields). |
| python/implicit_spline/paper_examples.py | Adds shared reference polygons/partitions used by demos and tests. |
| python/implicit_spline/init.py | Exposes new public APIs (cancel_internal_edges, convex_product_spline_2d, partition_basis_fields, validate_partition). |
| examples/README.md | Updates documentation to describe the corrected additive demo outputs and topology requirements. |
| examples/demo.py | Rewrites demo around additive construction, paper-style Section 7 examples, and conforming Section 9 partition identity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+549
to
+553
| edge_map = {} | ||
| for idx, P in enumerate(cells): | ||
| for p0, p1 in _polygon_edges(P): | ||
| key = _canonical_edge_key(p0, p1) | ||
| edge_map.setdefault(key, []).append((idx, np.asarray(p0), np.asarray(p1))) |
| raise ValueError( | ||
| f"validate_partition: total cell area {total_area} does not match outer area {outer_area}." | ||
| ) | ||
| outer_edges = {_canonical_edge_key(a, b) for a, b in _polygon_edges(outer)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current Section 7 and Section 9 implementations diverged from the Li–Tian construction: non-convex polygons were evaluated via signed distance / convex-piece composition, and partition cells were normalized post hoc instead of using the additive boundary formulation. This change restores the intended arbitrary-polygon spline behavior so direct evaluation matches convex decomposition and internal decomposition edges do not introduce seams.
Core spline construction
imp_spline_2dwith a boundary-based additive evaluator assembled from oriented edge contributions.B(whole polygon) == Σ B(convex cells)up to floating-point error.convex_product_spline_2d) instead of treating it as the general polygon algorithm.Geometry correctness
np.allclose(..., rtol=0, atol=...)for geometric tolerance checkstriangulate_polygonexplicitly require boundary-ordered vertices and fail if ear clipping cannot complete or does not return exactlym - 2triangles.Section 7 demo/content
Section 9 partition construction
partition_basis_fields) so the partition identity is expressed as the sum of polygon bases, not by normalizing arbitrary positive fields.Regression coverage
Example of the corrected decomposition path: