Skip to content

fix(saved-graphics): count cylinder trim crossings inside each strip - #2106

Merged
DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
shifatrHtH:codex/cylinder-trim-midpoint
Nov 20, 2026
Merged

DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
shifatrHtH:codex/cylinder-trim-midpoint

Conversation

@shifatrHtH

@shifatrHtH shifatrHtH commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Count a cylinder trim edge only when it crosses the midpoint of the open U strip. The endpoint tolerance still checks that the edge spans the strip.

Motivation

The two-loop cylinder path added by #2102 can count an edge outside a very narrow strip. It retains U knots at a tighter tolerance than the endpoint coverage check. On the synthetic two-ring case the wider check counts five crossings where the midpoint has four, and refuses the trim.

Changes

  • Use the strip midpoint for crossing membership in band_mesh.
  • Add a synthetic cylinder contract through the public research decoder. The case is tested beside band_mesh as a pure helper's failure modes (327a710f, by the maintainer; see the review comment), and 05b94b05 keeps each crossing on its ring edge.
  • A changelog fragment.

Testing

  • Merged main at d450e954 with the new contract fails with cylinder trim rings cross a strip an odd number of times.
  • With the patch, cargo test --offline -p rvt --profile ci --test integration cylinder_trim_contract:: passes. The recovered synthetic UV area is 3.000000000600.
  • cargo fmt --all -- --check, tools/ci/verify-real-files.sh --check-only, and python3 tools/release/changelog.py check passed.
  • tools/check-local.sh passed with its default checks. The optional external corpus and new Measure run remain pending.
  • The local private validation cleared this refusal and kept the other incomplete faces visible in diagnostics. A new public real-file Measure run would establish the wider export impact.

Maintainer's note: the first commit's contract is now three tests in src/research/native_saved_mesh.rs's test module, which CI's cargo test --profile ci --lib runs (all three pass on 05b94b05); the Testing lines above describe the first commit.

Audit-honesty checklist

  • The case verifies crossing membership and hole preservation on synthetic geometry.
  • The changelog records this narrow correction.
  • Broader export fidelity and performance are outside the synthetic contract.

Legal and contribution hygiene

  • The changes are suitable for Apache-2.0.
  • The contract uses an independently generated synthetic graph.
  • The diff contains generic source changes, synthetic test values, and its registration.

Breaking changes

None.

Output samples

before: cylinder trim rings cross a strip an odd number of times
after: cylinder_two_loops_keep_the_hole_across_close_u_knots ... ok

Related issues

Refs #1191 and #2102. Follow-up to the synthetic reproduction.

Use open midpoint membership to exclude edges that lie outside thin strips. The synthetic cylinder contract reproduces the odd crossing and verifies the cutout area.
@shifatrHtH

Copy link
Copy Markdown
Contributor Author

Thanks @DrunkOnJava. I built and tested 05b94b0 locally. All three strip regressions passed, including the near-coincident knot case with the clamp. The odd-crossing refusal is also gone in my local check, and the control mesh buffers match the earlier midpoint-only build byte for byte.

The next refusal I can still reproduce is shared edge surface samples disagree. When project(*uv) succeeds and the subsequent close check fails, would you start by tracing the side and sample pairing, or is there a branch already worth testing for the plane-versus-curved-surface agreement check? I can run a targeted trace locally and report only aggregate outcomes.

@DrunkOnJava

Copy link
Copy Markdown
Owner

Rows for this PR, registered before its Measure is read. The run is 44691150568: head 05b94b05 against main d450e954, every open model, exports kept. The held-out exports are not kept, so row 1 does not read them.

  1. Only bodies with a two-loop cylinder face may move: a body that moves must be one that feat(saved-graphics): a cylinder face bounded by two trim loops, a hole, two regions or a seamless tube, is meshed (#1191) #2102's Measure drew from its saved mesh or left refused with another reason.
  2. No refusal reason rises.
  3. No count of a scorer against Revit's exports falls.
  4. The same-project gates pass.

If they hold, this goes for review and lands. If a body moves that has no two-loop cylinder face, or a reason rises, that body is read before anything else. A fuller review follows.

@DrunkOnJava

Copy link
Copy Markdown
Owner

Thank you, @shifatrHtH. This is a real fault in what #2102 landed, and the fix is the right one: a ring edge counts for a strip only where it crosses the strip's midpoint.

What else it changes, and one more line. The old check also dropped any ring edge less than 1e-9 wide in U; the midpoint rule counts such an edge in the strips it spans. tessellation_axis joins knots closer than 1e-12 and keeps the smaller, so a strip can start up to 1e-12 before the edge it counts does. On an edge a few 1e-12 wide, at then reaches outside the edge by a large share of its height: on a ring whose right edge is 3e-12 wide and starts 0.5e-12 past the grid's 1.0, the crossing lands a sixth of the edge's height below the ring, by hand trace. So 05b94b05 keeps each crossing on its edge (at clamps its parameter to the edge), and the changelog fragment says so.

The test, moved (327a710f). CONTRIBUTING.md takes tests under tests/ that run a real entry point on a file, and a pure helper's failure-mode tests beside it in src/. tests/cylinder_trim_contract.rs built an object graph by hand and called the decoder, cylinder_face, so the commit removes it and its lines in tests/integration/main.rs and tools/ci/test-targets.txt. band_mesh is a pure 2D transform, and its test module in src/research/native_saved_mesh.rs now holds three cases:

  • yours, with your rings, your U grid (multiples of 0.125 and every ring knot) and your area, 3.0000000006;
  • the ring above, which no vertex leaves; it guards the clamp, and by hand trace passes on main too, where the old check counted a neighbouring edge in its place;
  • a ring edge along a strip's own edge is no crossing, which guards what the removed span check did, and by hand trace passes on main too.

All three pass in CI's lib tests on 05b94b05 (the build + real files / ubuntu-24.04 / stable job of 44691119039).

Your midpoint change is as you wrote it. The fragment and the PR body's Changes say what changed, with a note of mine in the body.

The rows for its Measure are registered in the comment above; I will post what the run shows against them.

Your next refusal, shared edge surface samples disagree. It is raised on the plane's side of an edge it shares with a cylinder, a surface of revolution, a ruled face or a cone (refined_plane_edge): each of the curved face's saved samples of the edge (the uv of the edge's own points on that face), evaluated on its surface and projected onto the plane, must land on the plane's saved uv of the same point. Before #2102 a plane beside a two-loop cylinder stopped earlier, at that cylinder's own refusal, so the check is new to those planes. If you can run 05b94b05 on your save, these counts would help: the bodies refused for odd strips before and after (the clamp is new since your run), and of the faces refused for samples that disagree, how many border a cylinder with two trim loops, by the curved face's surface class.

@shifatrHtH

Copy link
Copy Markdown
Contributor Author

@DrunkOnJava I ran the exact 05b94b05 head and traced the curved neighbour at the failing refined_plane_edge check in a separate local build. The before and after counts use the same selected bodies and controls.

Check Count
Bodies with an odd-strip refusal on #2102 at 968e15f8 9
Bodies with that refusal on #2106 at 05b94b05, including the clamp 0
Bodies with shared edge surface samples disagree on 05b94b05 9
Curved neighbour at a planar face refusal Face refusal occurrences
CylSurf, exactly two trim loops 18
CylSurf, any other loop count 0
SurfRev, RuledSurf, and ConeSurf 0 each

The trace labels the existing failure with the neighbour's class and counts the linked trim loops on that same face. These are face refusal occurrences across the tested bodies. They include two occurrences on each of the nine bodies with the new refusal. I checked that removing the diagnostic suffix yields the exact uninstrumented diagnostic counts, and the control mesh buffers match byte for byte. I can test a follow-up against this same local set.

@DrunkOnJava

Copy link
Copy Markdown
Owner

The registered rows hold on the full Measure (44691150568, 05b94b05 against d450e954; nordic, r2025, samples, holdout, every scorer, exports kept).

  1. Only bodies with a two-loop cylinder face move. 118 of 120 exports are byte-identical. On Snowdon Towers HVAC 12 meshes change and on Plumbing 72, and ifc_body_diff.py counts no other change on either. All 84 are bodies feat(saved-graphics): a cylinder face bounded by two trim loops, a hole, two regions or a seamless tube, is meshed (#1191) #2102's crack probe read for a two-loop cylinder face and no crossing edge (44663576285). All 84 were read, base against head: the 12 Round Tee:Standard and 72 IfcSanitaryTerminal (31 SinkConnection:Vanity, 21 Kitchen Sink, 15 Retail Sink, and one each of five others). On every one the vertex and triangle counts are the same, every vertex at the same index is where it was, and the largest distance of a head vertex from the base surface is 4e-15 m. On the tee read attribute by attribute, the points, triangles and normals are equal; one coordinate is -0.0 on the head where it is 0.0 on the base, which is what changes the export's bytes. So nothing moves on the open models. The held-out exports are not kept, and no held-out export moved.
  2. No refusal reason rises. All 102 diagnostics.json are byte-identical: no face that was refused is drawn, and none is newly refused. So no open model had an odd-strip refusal to clear; that the fix clears one rests on the lib test and on your private run, which predates the clamp.
  3. No count of a scorer against Revit's exports falls. No scorer line moves.
  4. The same-project gates pass on 05b94b05: 15 samples held to their earlier saves, and the Areas on 4 saves and on the 2021 save.

So this goes for review. The clamp in 05b94b05 is my own change to src/, so the approval that follows is partly a self-approval: the second reader is not running.

@shifatrHtH

Copy link
Copy Markdown
Contributor Author

Thanks for checking the 84 changed mesh records and the scorer rows, @DrunkOnJava. One clarification for row 2: the first scratch run predated the clamp. The later count includes the clamp at exact 05b94b05, where the same nine formerly refused bodies had zero odd-strip refusals.

@DrunkOnJava
DrunkOnJava merged commit d089085 into DrunkOnJava:main Nov 20, 2026
38 checks passed
@shifatrHtH

Copy link
Copy Markdown
Contributor Author

@DrunkOnJava I followed the remaining plane-to-cylinder refusal on the merged d089085b. In a diagnostic-only local build I evaluated each edge record's curved-side samples, projected them onto the plane, and compared the results to the plane-side samples from the same records.

  • All 18 refused edge occurrences pass the existing curved-point-to-plane residual check at every saved sample.
  • At each of the 18 edges, both endpoints and the interior sample fail the existing plane-UV close test. Reversing the curved sample order recovers zero pairs.
  • Every paired 3D gap is smaller than the default cylinder chord-error setting. These are non-isoparametric edges. The trace preserves the uninstrumented diagnostics and all four control mesh buffers.

The ordering check points toward a small disagreement between the two saved parameterizations. Do you have a source-backed rule for which face's samples take precedence on this edge, or a way to reconstruct an edge both loops agree on before tessellating? I can test a bounded candidate against this local fixture and the controls.

DrunkOnJava added a commit that referenced this pull request Nov 21, 2026
…lane's shared edge that the saved-mesh reader refuses as disagreeing, and the scorer reads which of them Revit's points follow (#2106)
DrunkOnJava added a commit that referenced this pull request Nov 21, 2026
…d edge, its ends included, leaves the plane's ring ends on those samples out of the floors, and prints each edge with --per-gap (#2106)
@DrunkOnJava

Copy link
Copy Markdown
Owner

@shifatrHtH, I missed this (your comment); sorry for the slow answer.

Which face's samples take precedence: no source-backed rule. Nothing rvt-rs reads says which face's samples win on such an edge. revit-ifc documents what Revit's exporter writes, not how Revit's tessellator meets two parameterizations of one edge, so it cannot give one either (CLEANROOM.md).

Rebuilding an edge both loops agree on: for an edge that crosses both of the cylinder's parameters, as yours do, that already exists once the saved samples agree.

So what lacks a rule is only which saved samples the rebuild starts from.

Measured on two public files. 29cd981b on research/2085-ring-join adds the reading:

  • the probe prints both faces' samples of each such edge, ends included, placed in model coordinates (edgesides);
  • the boundary scorer says, at each sample where the two faces are far enough apart to tell, which set Revit's own points sit on.

The exports' diagnostics name only an element's first refusal reason, so they undercount. In a full Measure run of main (102 files) they show this refusal on one element, the slab edge Slab Edge:Bleacher Seating (2059997) in Autodesk's Snowdon Towers Architectural 2024 sample, whose Revit IFC4 export is local here. The probe finds more.

The BIM4LCA housing (Measure 44946322653, against Revit's IFC4 Reference View export). Its 40 shared edges are one family's 8 edges, the basin Allas LE:PA-2.LE (IfcSanitaryTerminal), drawn on its 5 placements. Each edge has 3 samples, and the two faces' samples are up to 0.000255 ft (0.078 mm) apart.

  • At each edge's middle sample, its one interior sample:
    • on the 4 edges with a cylinder and the 2 with a surface of revolution, Revit has a point at each face's sample;
    • on the 2 edges with a cone, it has a point at the cone's sample and none at the plane's.
  • At the ends: an edge's ends are corners where a third face meets, so a point Revit has there may be that face's. A point at an end does not say whose it is, though its absence does. On the cylinder and revolution edges one end has a point at each face's sample and the other is too close to tell. On the cone edges one end has points at both, and the other a point at the cone's sample and none at the plane's.

Snowdon Towers Architectural: no rule. 20 elements reach a plane refused this way, with 82 shared edges, all with a cylinder, whose two faces' samples are more than 0.0000001 ft apart. The largest separation is 0.00012 ft (0.036 mm).

  • 68 of the 82 are on 17 walls, planter walls and floors that Revit's export draws as extrusions (IfcExtrudedAreaSolid). Those have no vertices to compare.
  • The other 14 are on three bodies made of polygons: the slab edge, a roof and a wall.
    • 11 are too close at every sample to tell, under twice the scorer's tolerance of at least 0.00001 ft.
    • On 3 edges of one roof face, at the 4 samples far enough apart to tell, Revit has a point at the plane's sample and none at the curved face's. All 4 are edge ends, so this is a few points on one face, not a rule.

So neither file shows one face's samples taking precedence as a rule. The only middle samples where one face's sample has a Revit point and the other's none are the basin's 2 cone edges, where it is the cone's. On your save, the same build gives the same reading for your edges:

git fetch https://github.com/DrunkOnJava/rvt-rs research/2085-ring-join
git checkout 29cd981b568b839d7f4e6a30c19e067c42d0c90a
cargo run --profile ci -p rvt-probes --example probe_2085_trim_breaks -- <your file>.rvt > probe.txt
python3 tools/re/boundary_gaps_vs_ifc.py probe.txt <your Revit export>.ifc

The install and Windows notes are those on #2085 (the rows there). Your 18 came from main's reader, and the probe runs this branch's, so please share the edge count its shared edges whose faces' samples differ line gives. That line gives the largest separation and, for each edge, plane's, curved face's, both, neither or split. All edges on one face's samples would be a rule measured on your save; neither, or a split, shows none. Either way, a rule that moves one face's samples onto the other's goes to Griffin as its own decision, with the measurement, before it is built.

@shifatrHtH

Copy link
Copy Markdown
Contributor Author

@DrunkOnJava, I ran the exact 29cd981b probe on the same arch save. It exited 0 with empty stderr. In the ten-target audit, nine have edgesides rows, with eight disputed edges each (72 total). All 72 are plane-to-cylinder edges. Each has three paired samples, including its two ends. All 216 paired separations exceed twice the scorer's minimum 1e-5 ft tolerance, and the largest separation is about 5.52 times that minimum. There were zero unread edge rows, zero unread graphics walks and zero disputed rows on the four controls.

The earlier 18 counted refused planar-face occurrences on main. The new 72 counts disputed shared edges in the research build. After excluding ring ends on disputed samples, 144 closed-end control rows remain, covering all nine targets reached by the edge probe.

The Revit-side read still needs an IFC export of this exact save. The RVT run establishes where the two stored placements are distinguishable at the minimum tolerance. The plane, cylinder, both and neither counts remain pending the same-save reference and its measured floor. Your two public cases are useful controls for the fact that a single face does not always win.

@DrunkOnJava

Copy link
Copy Markdown
Owner

@shifatrHtH, thank you for the run (your comment). That is the full reading the build gives without Revit's side: 72 plane-to-cylinder edges whose two faces' samples are more than twice the scorer's minimum tolerance of 0.00001 ft apart at all 216 samples, and no unread edge. Which face's samples Revit's points sit on waits for an IFC export of that save, as you say. With one, the same scorer command gives it per edge on its shared edges whose faces' samples differ line.

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