Skip to content

fix(saved-mesh): mesh a cylinder face trimmed by more than two loops - #2248

Open
oguzhanakk wants to merge 2 commits into
DrunkOnJava:mainfrom
sitekeephq:fix/cylinder-several-trim-loops
Open

oguzhanakk wants to merge 2 commits into
DrunkOnJava:mainfrom
sitekeephq:fix/cylinder-several-trim-loops

Conversation

@oguzhanakk

@oguzhanakk oguzhanakk commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

A cylinder face trimmed by more than two loops is meshed by the path two loops already take: the loops share the face's point budget (CYLINDER_RING_POINT_BUDGET / n) and band_mesh meshes them strip by strip across U with its even-odd rule. A full turn with several loops stays refused. Such a face was refused as multiple cylinder trim loops unsupported.

Motivation

RE-407 lists cylinder faces with an outer ring and two or more holes, or three outer rings, as a large reason elements stay record boxes (on Autodesk's 2024 samples, 26 + 3 + 2 of the 175 several-loop faces). Two loops are meshed today by band_mesh, which reads any number of rings: each strip collects every ring edge that spans it, sorts the crossings and fills between pairs, refusing an odd count. Nothing in it is specific to two.

RE-407 tested a different mesher (earcut per outer ring in arc-length coordinates, cut into strips) and did not ship it: 30 furniture of the BIM4LCA office read 1.11 times Revit's volume (the record box: 16 times), which it could not explain by the loops. This change adds no new tessellation; it lets more faces reach the strips the two-loop faces are already drawn with. Whether those 30 read differently with it I could not check (no BIM4LCA run here), and that is the check I would ask Measure for before it lands.

Changes

  • src/research/native_saved_mesh.rs, cylinder_face_with_shared_edges: every loop of the face is read (cycle-checked), each with CYLINDER_RING_POINT_BUDGET / n points; the budget, not a count of loops, bounds the work, and a loop given too few points is refused with the budget's own error. ring_gaps (the Family instances that stay boxes: expose symbol geometry and instance placement #2085 probe helper) splits the budget the same way.
  • changelog.d/fixed/cylinder-several-trim-loops.md.

Testing

Three pure-helper failure-mode unit tests next to the existing #2106 band_mesh tests (added in 9dbe86e after review): overlapping cutouts cut as their union (the reviewer's rings, 3.63), a crossing no single strip shows, and the two refusals. tools/ci/unit-test-counts.txt for this file goes from 61 to 64, so this needs the second maintainer review.

  • cargo fmt --check and tools/release/changelog.py check pass; cargo clippy --release --lib (Rust 1.100) finds nothing in the changed code (its one finding, enum_variant_names in partition_name_candidates.rs, is on main too).
  • Autodesk's sample projects (11 files, 2024-2027), main at a79664d against this branch: on rac_advanced (2024, 2026, 2027 alike) 7 elements move from record boxes to saved meshes (partition_element_record_bbox 216 -> 209, saved_graphics_mesh +7) and multiple cylinder trim loops unsupported goes from 7 to 0; nothing else changes on any sample; time and peak RSS within noise.
  • On private Revit 2023-2027 models: together with the pole change of fix(saved-mesh): read a revolved face's trim loop that steps along the surface's pole #2247, the instances of one device family, drawn today as record boxes many times the devices' size, are drawn from their saved meshes; on other models a few elements each move. A render of the device file shows the devices where boxes were. I cannot share the models or numbers from them.

Audit-honesty checklist

  • The volume question RE-407 raised is open for these faces too (see Motivation).

Breaking changes

None in the API. IFC output changes for the elements above.

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0.
  • No Autodesk proprietary source, decompiled internals or SDK content; the change reads only what rvt-rs already decodes.
  • No test fixture is added.
  • The commit is not signed; "Allow edits by maintainers" is on.

Related: #2243 (the same contributor's saved-mesh change for hollow framing and overrunning walls). This pull request is independent of it and applies to main on its own.

The two-loop path's strip mesher (band_mesh, even-odd across U) takes any
number of rings; the loops share the face's point budget. A full turn with
several loops stays refused.
@shifatrHtH

Copy link
Copy Markdown
Contributor

@oguzhanakk @DrunkOnJava I replayed this head at 1ab34bb3526a against its base b201137401d3 using Autodesk's public Revit 2026 MEP Basic sample, Fine Saved graphics, and SharedBoundary. The 17 doors refused at the base for multiple cylinder trim loops all decode on this head. A local intersection guard preserves all 17 primitive digests.

The guard also catches a separate synthetic case. On a partial cylinder of radius 2, use a UV outer rectangle from (0, 0) to (1.7, 3) and cutout rectangles from (0.2, 0.3) to (0.8, 1.5) and from (0.5, 0.8) to (1.3, 2.0). This head emits UV area 3.84 because the overlapping part is filled. Removing the union of the cutouts leaves area 3.63. My conservative trial refuses the intersecting rings and still emits area 4.23 on a separate-hole control.

There's also a seam check worth keeping separate from ring admission. The replay has 57 distinct solid carriers across those 17 doors. This head closes 40 across the three weld sizes and eight grid phases I tested. Giving both adjacent faces the same ordered trim subdivisions closes 57/57 and removes the one-sided edges on every grid. That comparison is against the saved reader geometry. I have yet to find a matching Revit export for this Autodesk sample.

Would you prefer the synthetic crossing-ring guard as a small follow-up to this PR, with shared-edge conformity reviewed separately? I can provide the generated graph and the public replay harness.

…union

band_mesh fills between a strip's crossings by the even-odd rule, so two
cutouts that overlap left the part they share filled (shifatrHtH's rings on
DrunkOnJava#2248: 3.84 where the outer ring less the cutouts' union is 3.63). Rings
that cross are now found first, at both sides of every strip, where the
spans are exact: those one ring encloses together are drawn as their union,
and a crossing with no ring round it (a cutout across the outer boundary,
pieces that overlap) or one between two knots is refused. Faces whose
rings do not cross are meshed as before.

Three failure-mode tests of the pure helper (the reviewer's rings, a
crossing no single strip shows, the refusals) raise the file's count to 64.
@oguzhanakk

Copy link
Copy Markdown
Author

@shifatrHtH thank you for the replay and for the crossing-ring case. It's a real bug in this PR, so I've fixed it here rather than in a follow-up.

Pushed 9dbe86e. band_mesh now finds rings that cross before it fills a strip. Two rings cross where they share area and neither lies inside the other. It checks this at both sides of every strip, so it also catches a crossing that no single strip shows (one cutout inside the other between two knots, beside it past them). Crossing rings that one ring encloses together, as overlapping cutouts are, are cut as their union. Any other crossing refuses the face, which then falls back as before. That covers a cutout across the outer boundary or overlapping pieces, where it isn't known which ring is the cutout, and two edges crossing between knots. Faces whose rings don't cross are meshed exactly as before.

Your rings are now a unit test: 3.63, and 4.23 with the second cutout moved clear (my own control, not necessarily the one you used). Two more tests cover the failure modes: the crossing no strip shows, and the refusals. Under the pure-helper rule that raises the file's count from 61 to 64, so it needs the second maintainer review.

On the public Revit 2026 MEP Basic sample, the 17 doors still decode, and the IFC is byte-identical to the previous head, so their meshes are unchanged. The 11 Autodesk RAC/RST samples show no change against the previous head.

Shared-edge conformity: agreed, let's review it separately. 57/57 closed with the same ordered trim subdivisions on both faces is a strong result. I'd welcome the generated graph and the replay harness for that follow-up.

@shifatrHtH

Copy link
Copy Markdown
Contributor

@oguzhanakk I independently replayed 9dbe86ed against 1ab34bb3 on Autodesk's public Revit 2026 MEP Basic sample. All 17 affected doors still decode, with identical native geometry digests and 41,220 triangles in both arms. The generated overlap now leaves 3.63 UV area (previously 3.84), and the separate-cutout control still leaves 4.23. Thanks for adding the between-knot and refusal cases.

I agree with keeping shared-edge conformity in a separate review. The 57/57 closed-carrier result is from the earlier opt-in seam trial. I'll use 9dbe86ed as the crossing baseline for that follow-up and rerun the public topology checks so those results can be attributed to the seam change alone.

shifatrHtH added a commit to shifatrHtH/rvt-rs that referenced this pull request Dec 4, 2026
Keep the crossing-ring mesher from DrunkOnJava#2248 and add a scoped conforming retry for plane and cylinder carriers. The retry commits only closed oriented triangle sets. Include a generated graph and a replay for the public Revit 2026 Basic MEP doors.
@shifatrHtH

Copy link
Copy Markdown
Contributor

@oguzhanakk The separate shared-edge follow-up is ready to replay from the exact 9dbe86ed head. Here are the public replay instructions and the generated plane–cylinder graph. The branch isolates the prepared-chain policy so it can be reviewed independently of the crossing fix.

On Autodesk's public Revit 2026 Basic MEP sample, the disabled arm matches the unmodified head on all 17 doors. The candidate closes 57/57 source carriers at all 24 weld grids, up from 40/57, with zero one-sided edges, nonmanifold edges, or winding conflicts per carrier. The enabled vertex, index and ledger buffers reproduce byte for byte. The candidate is within 0.000562 ft of the disabled arm in both sampled directions. That delta compares two reader outputs. A same-save Fine Revit capture is still needed for the independent surface check.

The generated graph closes four planes and two cylinder patches with opposed edge incidence and refuses a displaced stored sample. The union and separate-cutout controls still measure 3.63 and 4.23 UV area. The candidate stays opt-in, and the signed branch is available for review without adding another PR to the queue before #2248 lands.

This branch has not been deployed

No deployments
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