Skip to content

fix(saved-mesh): close planar edges at used trim stations - #2256

Closed
shifatrHtH wants to merge 2 commits into
DrunkOnJava:mainfrom
shifatrHtH:codex/planar-boundary-stations
Closed

shifatrHtH wants to merge 2 commits into
DrunkOnJava:mainfrom
shifatrHtH:codex/planar-boundary-stations

Conversation

@shifatrHtH

Copy link
Copy Markdown
Contributor

Summary

Saved planar faces now split a one-sided triangle edge at a collinear trim station even when another triangle already uses that vertex. The fix preserves the authored vertex positions and removes the T-junction.

Motivation

Issue #2250 shows a complete Saved mesh in RE1 Mechanical with three one-sided edges. Earcut uses the relevant station in one triangle but leaves a longer edge through it in the neighboring triangle. The existing boundary restoration treats an already-used index as restored.

Changes

  • Search used boundary stations within the edge's dominant model-space coordinate interval. Apply a physical collinearity check and keep the original triangles if the bounded split cannot preserve winding and nonzero area.
  • Include a public RE1 Mechanical probe and a two-binary replay script.

Testing

  • tools/check-local.sh
  • The public IFC-ECS RE1 Mechanical pair is MIT-licensed and checksum-pinned in the witness registry. The affected carrier goes from 27 to 28 triangles and from three to zero one-sided edges at each of the three weld tolerances. Its vertex buffer is byte-identical. The whole element's bidirectional vertex, edge-midpoint and centroid comparison against the paired Revit IFC stays within 3e-14 ft in both arms.
  • The default and SharedBoundary paths each replay 1,159 selected owners across 23 public RVT/IFC pairs. In each path, 74 rows change geometry, with no identity or refusal changes. In the measured SharedBoundary arm, all 61 complete changed owners keep their vertex buffers, and 79 changed carriers close at all three welds. The bidirectional IFC distance maxima are unchanged for all 61.
  • @DrunkOnJava, could you run full Measure on this head before landing?
  • N/A for tools/bench.sh. This is a topology fix.

Copy probes/examples/probe_2250_planar_boundary_stations.rs into the base checkout at b2011374 and build the probe in each checkout.

cargo build --locked --profile ci -p rvt-probes --example probe_2250_planar_boundary_stations
python3 -B tools/re/replay_planar_boundary_stations.py BASE_PROBE HEAD_PROBE RE1-Mechanical.rvt

Audit-honesty checklist

  • The changelog describes only the planar edge repair. There is no public API change or new format claim.
  • The probe uses a public fixture from the witness registry.
  • N/A for reverse-engineering documentation. This corrects triangulation of existing decoded rings.

Legal and contribution hygiene

  • This contribution is licensable under Apache-2.0 and uses publicly documented inputs.
  • No model files or third-party implementation code are included.

Breaking changes

None.

Screenshots or output samples

{"publicElementId":439148,"oneSidedEdges":[3,0],"carrierTriangles":[27,28],"vertexBufferIdentical":true}

Related issues

Refs #2250.

Earcut can use a boundary station in one triangle and leave a longer one-sided edge through it. Split the incident triangle at the stored station while preserving vertex positions and winding.

Refs DrunkOnJava#2250.
@DrunkOnJava

DrunkOnJava commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

@shifatrHtH, thank you. The full Measure run you asked for is going on this head, against its merge base b2011374: 47461981522. I'll post what it shows here.

One thing from reading the code against main at 5b7d7042: plane_mesh now counts the new conform step in its own counter (conform_work, capped at MAX_PAIRS, 1,000,000), set once per face. native_saved_mesh.rs (2603-2611) documents PLANAR_WORK_BUDGET as the most work one planar face may ask in all, counted by retain_boundary_points_within and split_pinched_rings. With the new step outside it, a face can ask up to another million beyond that bound, so that doc no longer holds. Either the step joins the face's count, or the doc says the face's bound is the sum. The budget was sized from the corpus's largest measured face, so which one is your call.

@DrunkOnJava

DrunkOnJava commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

@shifatrHtH, the full Measure run on 7bff89b3, against its merge base b2011374: 47461981522 (every scorer, the BIM4LCA models, the Revit 2025 set and Autodesk's samples).

  • Exports. 43 of 101 change; diagnostics.json changes on 16. On the two I read (rme_basic 2024 and the 2025 stairs model), only total_entities moves, which fits your "no identity or refusal changes".

  • Quantities (qtos_vs_ifc.txt). Base quantities equal to Revit's rise on every BIM4LCA model:

    • +38 and +42 on the concrete housing (as built, permit), +26 and +22 on the timber housing;
    • +36 on each terrain model;
    • +93 and +89 on the concrete office, +106 on each timber office;
    • +3 on each of six Revit 2025 room and stair models.

    That is 612 more equal values, mostly walls' GrossSideArea and GrossVolume, beams' areas and proxies' NetVolume, each one moving from missing. different stays where it was (0, or 1 on the offices), and so does "rvt-rs quantities Revit does not write". On RE1 Architecture, whose export has base quantities turned off, rvt-rs writes 5 more (127 against 122); those are counted apart there.

  • Bodies. mesh_bodies_vs_ifc changes only in order: two furniture lines on the office permit model swap places, with the same values. wall_heights_vs_ifc reads a few more triangles on four housing models.

  • MCP answers. mcp_answers_vs_ifc.txt moves on 15 models, in the same direction: fewer property or quantity values Revit writes that the answers lack.

  • Gates. same-project gates pass on this head: 15 samples held to their earlier saves, and the Areas.

  • Still to read before it lands: the held-out models (47467256394, running).

@shifatrHtH

Copy link
Copy Markdown
Contributor Author

@DrunkOnJava Thanks for running Measure and flagging the budget. Commit 86ca5d04 charges every conform pair check against the same PLANAR_WORK_BUDGET as boundary restoration and pinch splitting. The one-million-pair limit remains a sublimit and is shared across all rings and the pinch retry. If either limit is exhausted, the optional pass leaves the existing triangles in place.

In a generated T-junction, the split succeeds with exactly the required checks available. With one fewer check it leaves the original triangles in place, with no charge above either limit. On the checksum-pinned public RE1 Mechanical fixture, the affected carrier still goes from 27 to 28 triangles and from three to zero one-sided edges at all three weld tolerances. Its vertex buffer is byte-identical. Across the same 23 public fixtures, the new head matches all 1,159 selected rows from 7bff89b3 in each of the default and SharedBoundary arms, including geometry digests and refusal states. Formatting and scoped Rust Clippy passed.

Your 612 added Revit-matching quantities and the same-project gate results are useful. Once the held-out comparison on 7bff89b3 is available, could you run Measure on 86ca5d04 to check whether the new budget accounting changes any exports in the wider corpus?

@DrunkOnJava

Copy link
Copy Markdown
Owner

@shifatrHtH, thank you for 86ca5d04. The conform step now counts in the face's work, and stops instead of failing at its pair limit. Its result was already only used when it succeeded (if let Ok(Some(conformed))), so a face past the limit keeps its validated triangulation as before. Three things:

  • Held out, on 7bff89b3. The 18 held-out models (47467256394, against the merge base b2011374): 10 exports change. Base quantities equal to Revit's rise by 193 in all (+2 on AA-SingleDwellingHouse, +15 on modelo_bim, +24 on each of the four rvt-holdout saves, +20 on each of the four rvt-holdout-office saves), each one moving from missing. different and "rvt-rs quantities Revit does not write" are unchanged on all 10.
  • This head. Measure 47469206258 puts 86ca5d04 against 7bff89b3, unfiltered, with every scorer and Autodesk's samples: 101 of 101 exports and diagnostics are identical, no scorer output differs, and the same-project gates pass on 86ca5d04. So the work count changes no export of those 101. The held-out models were not in that run.
  • Two tolerances. The conform step splits an edge only at a station within DISTANCE_FT = 1e-10 ft of it, while the reader takes two points as one within 1e-7 (close(), native_saved_mesh.rs 152-154 at main). A station between 1e-10 and 1e-7 ft off an edge is the same point to the reader but is not conformed. Whether any face of the corpus has one is not measured.

Neither of your two commits is signed, which the branch rules require; I'll re-sign them when it lands, keeping you as their author.

@DrunkOnJava

Copy link
Copy Markdown
Owner

@shifatrHtH, the count I said I'd run. A scratch build of your 86ca5d04 that only adds the count (c508ff10) measured, on every planar face the conform step reaches, how far each boundary station lies off each boundary edge it falls along: Measure 47620668497, with Autodesk's samples, the BIM4LCA models and the Revit 2025 set.

  • None lies between 1e-10 and 1e-7 ft off an edge. So on these files the conform step's 1e-10 limit leaves no station unsplit that the reader would take as the same point.
  • What it covered: 82 of 101 models reach the step, with at least 1,424,346 planar faces and 11.4 million boundary stations. Each model's figure is a floor, read from its last progress line. No face reached it on the other 19: the 2015 to 2022 saves of Autodesk's rac_advanced, rst_basic and rst_advanced samples, and one empty Revit 2025 model. The held-out models weren't in this run, and a face past the work budget isn't counted.

Next, ours: carry your two commits onto current main, re-signed with you as their author as I said, run Measure on that against main, and report the result here.

DrunkOnJava added a commit that referenced this pull request Dec 6, 2026
…rrying #2256 (#2296)

## Summary

Saved planar faces now split a one-sided triangle edge at a collinear
trim station, even when another triangle already uses that station, so
the face closes without a T-junction. On the BIM4LCA and Revit 2025
models, walls (`IfcWall`) gain `Height`, `GrossSideArea`, `GrossVolume`
and their net values, beams (`IfcBeam`) their surface areas, volumes and
`CrossSectionArea`, and proxies their `NetVolume`, each moving from
missing to equal to Revit's; no value moves to different. No body
changes its source: the only field that moves in any `diagnostics.json`
is `total_entities`. This carries shifatrHtH's #2256 onto current
`main`: their two commits, cherry-picked onto current `main` and
re-signed with them as author, plus the changelog credit. The
cherry-pick merged `native_saved_mesh.rs` automatically, since #2276 to
#2280 have changed it since #2256's base. Supersedes #2256.

Closes #2250.

## Motivation

#2250: a complete saved mesh in RE1 Mechanical has three one-sided
edges. Earcut uses a boundary station in one triangle but leaves a
longer edge through it in the neighbouring one, and the existing
boundary restoration treats an already-used station as restored. The
branch rules require signed commits, which #2256's two aren't.

## Changes

- `src/research/native_saved_mesh.rs` (shifatrHtH):
`conform_used_planar_stations` splits a one-sided edge at each used
boundary station within 1e-10 ft of it, keeping the authored vertex
positions, the winding and a nonzero area, or else keeps the validated
triangles. Its checks count against the face's `PLANAR_WORK_BUDGET`,
with a pair limit of 1,000,000 shared across its rings.
- `probes/examples/probe_2250_planar_boundary_stations.rs` and
`tools/re/replay_planar_boundary_stations.py` (shifatrHtH): a public RE1
Mechanical probe and a two-binary replay.
- `changelog.d/fixed/planar-boundary-stations.md`, with "Contributed by
shifatrHtH."

## Testing

- **The carry against `main`, unfiltered.** Measure
[47623397328](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47623397328)
on `9c2389fb` against `main`, with the samples, the BIM4LCA models and
the Revit 2025 set. Registered before the run: the 43 exports and 16
`diagnostics.json` that #2256's own head moved against its merge base
([47461981522](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47461981522)),
with the same quantity gains. Result: 43 of 101 exports differ, the same
43 by name, and the same 16 `diagnostics.json`, in each of which only
`exported.total_entities` moves (no body source, refusal or skipped
count). Every scorer line that differs is in four scorers: `qtos_vs_ifc`
(missing to equal, below), `mcp_answers_vs_ifc` (the same quantities in
the server's answers, 15 models), `wall_heights_vs_ifc` (2 to 5 more
triangles read on four housing models) and `mesh_bodies_vs_ifc` (two
equal furniture lines swap places on the office at permit), as on
#2256's own run. Base quantities equal to Revit's rise by 612 with the
same split by model: +38 and +42 on the concrete housing, +36 on each
terrain model, +26 and +22 on the timber housing, +93 and +89 on the
concrete office, +106 on each timber office, and +3 on each of six Revit
2025 room and stair models. `different` and "rvt-rs quantities Revit
does not write" are unchanged on all 16. The same-project gates pass on
`9c2389fb`.
- **Held-out and BIMcollab models.** Measure
[47623399402](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47623399402),
same head: the 10 held-out exports #2256's head moved
([47467256394](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47467256394)),
plus RE1 Architecture and RE1 Mechanical, which #2256's unfiltered run
also moved. 7 of 7 diagnostics identical. Equal base quantities +193
with the same split (+2, +15, +24 on each of four saves, +20 on each of
four saves); `different` and "values Revit does not write" unchanged. On
RE1 Architecture, whose export has base quantities off, rvt-rs writes
127 against 122, counted apart.
- **#2250's case on current `main`.** shifatrHtH's probe of RE1
Mechanical's element 439148, with a scratch count of the edges each
carrier uses once, vertices welded by position at 1e-7 ft (Measure
[47629195459](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47629195459)
on `main` plus the probe,
[47629193042](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47629193042)
on this carry plus the probe; both scratch commits archived under
`refs/archive/2026-12-06/`): 3 one-sided edges and 83 triangles on
`main`, 0 and 84 here, as #2250 reports.
- shifatrHtH's 1,159-row replay of 23 public pairs ran on #2256's head
against `b2011374` and hasn't been rerun on this carry.
- The station tolerance: of at least 11.4 million boundary stations on
the 82 models that reach the conform step, none lies between 1e-10 and
1e-7 ft off an edge
([47620668497](https://github.com/DrunkOnJava/rvt-rs/actions/runs/47620668497),
posted on #2256).
- No unit tests.

## Breaking changes

None.

Co-authored-by: shifatrHtH
<342213537+shifatrHtH@users.noreply.github.com>

---------

Co-authored-by: shifatrHtH <342213537+shifatrHtH@users.noreply.github.com>
Co-authored-by: shifatr <shifatr@harrythehirer.com.au>
@DrunkOnJava

Copy link
Copy Markdown
Owner

@shifatrHtH, this landed as #2296 (b8f19df0), squashed from your two commits with you as co-author, and the changelog credits you. Measured on current main, it moves the same 43 exports as your head did, with the same 612 more base quantities equal to Revit's, and the same 193 on the held-out models; nothing moves to different. On RE1 Mechanical's element 439148 the one-sided edges go from 3 to 0, as you reported, and #2296 closes #2250. It ships in 0.28.0. Thank you for it, and for the replay that made it easy to check. I'm closing this one in favour of #2296.

@DrunkOnJava DrunkOnJava closed this Dec 6, 2026
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.

2 participants