Expose the coplanar-group map of the input triangles - #24
Merged
Conversation
out_triangle_provenance is indexed by coplanar group, and until now nothing in the API said which group an input triangle landed in. A caller therefore got per-group lists of output faces with no way back to the input, and so no way to carry a per-triangle attribute -- a material tag, which input file a surface came from -- through the arrangement. The mapping was already computed (BSPcomplex::constraint_coplanar_group, filled by computeCoplanarGroups) and even dumped by the -g debug writer; it was just never returned. Add out_triangle_group, one entry per input triangle. It is composed with constraint_original_index rather than returned raw: constraint indices are not input triangle indices, because read_nodes_and_constraints drops degenerate (misAlignment) triangles as it copies, compacting everything after them. A dropped triangle gets UINT32_MAX -- it contributed nothing to the arrangement and belongs to no group. Edge- and point-forcing triangles are grouped internally but carry no original index, so they never name a slot. Also add tests/unit_tests_3d.cpp: the first unit tests for the 3D embedding API that CI actually runs. embed_regression covers a real model but is hidden behind Catch2's [.] because it takes over an hour; these use a six-tet cube and four triangles and finish in well under a second. They pin the three cases that matter -- edge-adjacent and coplanar triangles share a group, an edge-adjacent but folded triangle does not, and a degenerate triangle maps to UINT32_MAX with the surviving triangles still on their own input indices. The degenerate triangle sits in the middle of the input on purpose, so a map that returned the internal constraint numbering fails rather than passing by coincidence (verified: it does). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
out_triangle_provenanceis indexed by coplanar group, and nothing in the API said which group an input triangle landed in. A caller therefore received per-group lists of output faces with no way back to the input — and so no way to carry a per-triangle attribute (a material tag, which input file a surface came from) through the arrangement.The mapping was already computed:
BSPcomplex::constraint_coplanar_group, filled bycomputeCoplanarGroups(), and even written out by the-gdebug dump. It was simply never returned.This adds one output to
embed_tri_in_poly_mesh:Why it is composed, not returned raw
Constraint indices are not input triangle indices.
read_nodes_and_constraintsdrops degenerate (misAlignment) triangles as it copies them, compacting everything after them, and records the original index intri_original_index. So the new output composes the two maps and hands back the caller's own numbering:UINT32_MAX— it contributed nothing to the arrangement and belongs to no group;Tests
tests/unit_tests_3d.cppis new — the first unit tests of the 3D embedding API that CI actually runs.embed_regressioncovers a real model but is hidden behind Catch2's[.]tag because it takes over an hour; these use a six-tet cube and four triangles and finish in well under a second.They pin the three cases that matter:
UINT32_MAX, later triangles still on their own input indicesThe degenerate triangle sits in the middle of the input on purpose: with it last, a map that returned the internal constraint numbering would pass by coincidence. Verified as a negative control — reverting the composition to the identity makes the test fail.
embed_regressionalso gained a cheap invariant check on the new output.Local
ctest: full suite green.