Skip to content

fix(levels): a non-storey Level may share a storey's elevation (#746) - #752

Merged
DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
helenkwok:fix/levels-shared-elevation
Oct 18, 2026
Merged

DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
helenkwok:fix/levels-shared-elevation

Conversation

@helenkwok

Copy link
Copy Markdown
Contributor

Refs #746. On BIM4LCA ARK_NordicLCA_Housing_Timber_BuildingPermit.rvt and _As-Built.rvt (public, CC BY-SA 4.0), main recovers no Level, so every element falls back to one storey at 0.

Cause: recovered_levels_are_a_storey_set rejects the whole level set when any two recovered Levels share an elevation. These files have a reference level Bet 1-lattia (not a building storey) at Level_01's 170.6037 ft. The records and name/elevation blocks for all eight storeys are found correctly (examples/probe_level_records); only this check drops them. The concrete sibling has no such pair, which is why it works.

Fix: hold only building storeys (building_story != Some(false)) to distinct elevations. One line in src/partition_level_records.rs.

Measured:

  • Housing_Timber BuildingPermit and As-Built: Revit's eight storeys at Revit's elevations (0, 47.3, 49.07, 52.0, 55.144, 58.458, 61.772, 64.677 m), with Revit's names. All 54 columns of the As-Built file are then on the same storey as in Revit's export.
  • racadvanced, racbasic, rmeadvanced and rstadvanced (Autodesk 2024 samples): element counts and storeys identical to main 120e2f9. Housing_Concrete and Office_Concrete BuildingPermit keep their storeys.
  • Integration suite: same result as main (one pre-existing failure, ifc_synthetic_project::synthetic_project_emits_valid_ifc4, fails on main too).

Test: tests/level_shared_elevation.rs, corpus-gated on RVT_NORDIC_LCA_DIR (the file is fetched by URL and sha256, listed in corpus/tier2/README.md, not committed). It fails on main (storeys recovered: []) and passes with the fix.

Not fixed here: #746's columns still start at z = 0 (their records have m_locationZ = 0.0 and no constraint levels), so their geometry still spans from the ground. That needs the column's base Level for its placement, which is a separate change.

Clean-room: based on public BIM4LCA files and Revit's own IFC4 export of them, read with rvt-rs's existing probes. No Autodesk SDK source, ODA SDK source, leaked documentation or decompiled code.

…OnJava#746)

recovered_levels_are_a_storey_set rejected the whole level set when any two
recovered Levels had the same elevation. On BIM4LCA Housing_Timber_* the
reference level 'Bet 1-lattia' sits at Level_01's 170.6037 ft, so no Level was
recovered and every element fell back to one storey. Hold only building
storeys to distinct elevations.

Housing_Timber_BuildingPermit and _As-Built now give Revit's 8 storeys at
Revit's elevations (0, 47.3, 49.07, 52.0, 55.144, 58.458, 61.772, 64.677 m);
racadvanced, racbasic, rmeadvanced and rstadvanced storeys are unchanged.
…nkOnJava#746)

Corpus-gated on RVT_NORDIC_LCA_DIR (CC BY-SA 4.0, fetched by URL, not
committed). Fails on main (no storeys recovered), passes with the fix.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 18, 2026 08:48
@DrunkOnJava
DrunkOnJava merged commit 7ba5472 into DrunkOnJava:main Oct 18, 2026
25 checks passed
DrunkOnJava pushed a commit that referenced this pull request Oct 18, 2026
…ry node (RE-173) (#753)

Refs #746. Some column records hold a box that starts at exactly z = 0.0 while the column starts higher, so rvt-rs draws those columns from the ground. This affects 131 of the 135 columns in Autodesk's `rmeadvancedsampleproject` (Revit 2024), all 54 in BIM4LCA `Housing_Timber_As-Built` (#746), and all 7 in `Housing_Concrete_BuildingPermit`.

**Where the right value is.** Revit also stores the instance's geometry node. In the inflated `Partitions/*` streams the column's `u64` ElementId occurs again as `u64 id · u64 3 · u64 0xffffffffffffffff`, with two boxes of six `f64` (min x, y, z, max x, y, z) at 96 and 48 bytes before the id. The two boxes have the same x and y extents, and the second holds Revit's z-range. The schema class tags around them are `GArray` (`0x0820`, parent `GInstance`) and `GRep` (`0x0841`). A column can have several such nodes, and they do not always agree.

**The rule (fail closed).**

- It applies only to a `Column` or `StructuralColumn` whose record box starts at exactly 0.0.
- A node counts when both of its boxes are finite with max above min, their x and y extents are equal and match the record's to 1e-6 ft, its top equals the record's top (within 0.01 ft), and its bottom differs from the record's.
- The bottom moves only if every counting node gives the same bottom. The top is kept.
- The element is marked `m_column_z_source = partition_geometry_node`.
- Revit 2024 only.
- Cost: one `memchr::memmem` pass per partition, only when a column starts at 0.0.

**Measured against Revit.** Autodesk files use Revit's Base Level + Base Offset and Top Level + Top Offset parameters; the BIM4LCA files, whose export has no Revit parameters, use the geometry in Revit's IFC4 export.

| file | columns | rewritten | rewritten and equal to Revit | not rewritten |
|---|---:|---:|---:|---|
| rmeadvanced | 135 | 131 | 131 | 4, already right |
| Housing_Concrete_BuildingPermit | 7 | 7 | 7 | 0 |
| Housing_Timber_As-Built | 54 | 54 | 54 | 0 |
| racadvanced | 176 | 0 | | 176 right by Revit's exported geometry (see note) |
| rstadvanced | 203 | 0 | | 203 right |
| racbasic | 3 | 0 | | 3 right by Revit's exported geometry (see note) |
| Office_Concrete_BuildingPermit | 346 | 0 | | unchanged |
| Office_Timber_BuildingPermit | 340 | 0 | | unchanged |

No column that main gets right is changed.

**Note on racadvanced and racbasic.** An earlier version of this table counted 12 racadvanced columns and 1 racbasic column as wrong. That came from comparing with Revit's exported parameters. For the 12 racadvanced columns Revit's IFC writes Base Offset, Top Offset and Length in feet divided by 304.8, labelled as millimetres (column 201277: Base Offset `-0.013123` = -4 ft, Top Offset `0.006562` = 2 ft, Length `0.019685` = 6 ft). The racbasic column (414482, a drop-cap column) has parameters giving a top of 10.171 ft, while Revit's own exported body tops at 2980 mm = 9.777 ft, as here. Revit's exported body geometry agrees with main and with this PR on all 176 racadvanced columns and on that racbasic column.

**Not covered.** Columns whose record box does not start at 0.0 are never touched; on these samples none of them is wrong. Revit 2023 and 2025 are not checked. On `Housing_Timber_*` the storeys still need #752; this rule does not need Levels.

**Test.** `tests/column_node_z.rs`:

- **Required data:** `RVT_NORDIC_LCA_DIR` with `ARK_NordicLCA_Housing_Concrete_BuildingPermit.rvt` (CC BY-SA 4.0, BIM4LCA; fetched by URL and sha256 as listed in `corpus/tier2/README.md`, not committed). The 7 columns' bottoms and tops must equal Revit's.
- **Optional check:** with `RVT_REVIT2024_SAMPLES_DIR` and `rmeadvancedsampleproject.rvt`, at least 131 columns must start above z = 0.
- **Result:** both fail on main (`1406153: bottom 0, Revit 170.60367454068242`) and pass with the change.

`cargo fmt --check`, clippy `-D warnings` and `cargo doc -D warnings` pass. The integration suite gives the same result as main: one pre-existing failure, `ifc_synthetic_project::synthetic_project_emits_valid_ifc4`, which fails on main too. Report: `reports/element-framing/RE-173-column-z-from-geometry-node.md`.

Clean-room: based on public Autodesk Revit 2024 sample files, public BIM4LCA files, Revit's own IFC4 export as the oracle, and the file's own schema and exported symbol names only. No Autodesk SDK source, ODA SDK source, leaked documentation or decompiled code.
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
[Unreleased] becomes [0.5.0] — 2026-10-18, with an introduction, the
contributors, and what to change when upgrading from 0.4. The community
pull requests' entries are added and credited (#737, #738, #744, #751,
#752, #753, #755, #757, #758), and the repeated Added, Changed, Fixed and
Research headings are folded into one each, keeping every entry (107) and
its order; everything from [0.4.0] down is unchanged.

CITATION.cff said 0.1.2 (2026-04-20), though RELEASE.md has it agree with
Cargo.toml at every tag. Its abstract now describes the project as the
README does, without the "first open-source tool" and "verified against
11 releases" claims.
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
## Summary

Prepare v0.5.0. Merging this is not the release: the release is the signed `v0.5.0` tag on the merged commit, which runs `publish.yml` (crates.io, PyPI, the release binaries and the container image). The tag waits for the maintainer's go-ahead.

## Motivation

`main` is 0.4.0 plus everything under `[Unreleased]`: Revit 2026 projects (experimental), MEP ports, connections and systems, Revit's level, category, family, type and phase properties, rooms aggregated into their storeys, Snowdon Towers exporting again, and the first pull requests from outside contributors. Before 1.0 a breaking change bumps the minor version, and these are breaking for a 0.4 user:

- The MSRV is 1.87 (was 1.85).
- `rvt` has no `wasm` feature; the bindings are the `rvt-wasm` crate (C6).
- Each `IfcSpace` is aggregated into its storey instead of contained in it (#744).
- `ElemTableHeader::record_count` is a `u32` (#764).
- Type objects take Revit's GlobalIds (RE-167).

## Changes

- **Versions 0.4.0 → 0.5.0:** `rvt`, `rvt-py` and its pin, `rvt-wasm`, the `stream_evidence` pin, both lockfiles (only the workspace crates' version lines change), `.release-please-manifest.json` and `viewer/package.json`.
- **`CHANGELOG.md`:** `[Unreleased]` becomes `[0.5.0] — 2026-10-18`.
  - An introduction, the contributors, and an **Upgrading from 0.4** section.
  - The community pull requests' entries are added and credited (#737, #738, #744, #751, #752, #753, #755, #757, #758).
  - The repeated Added, Changed, Fixed and Research headings, which later merges had appended, are folded into one each. All 107 entries are kept as written (checked as a multiset) and in their order, and everything from `[0.4.0]` down is byte-identical.
  - #778's clean-room policy change is added under Changed, so the section has 108 entries.
- **`CITATION.cff`:** it said 0.1.2 (2026-04-20), though `RELEASE.md` has it agree with `Cargo.toml` at every tag. Its abstract now describes the project as the README does, without the "first open-source tool" and "verified against 11 releases" claims.
- **Registry descriptions:** crates.io showed 0.4.0's description, which leaves out Revit 2023, and PyPI one that called element extraction and geometry "active research" and the export "document-level IFC4 scaffolding". `Cargo.toml` and `pyproject.toml` now say what the README says: typed elements from Revit 2023 to 2025 projects, 2026 experimental.
- **Witnesses:** the IFC header carries the version (#417), so both Core Interior `rvt-rs.json` observations and their verdicts are refreshed from this pull request's CI run.

## Testing

- CI on this pull request: every job `CI passed` requires, the witness replays among them.
- On the tag, the publish workflow runs its own checks before anything is published: wheel install and model open on each OS, `cargo install` and the CLI sample smoke, the docs.rs build preview and the viewer load smoke. crates.io and PyPI publish only after all of them pass, and PyPI only after crates.io.

## Audit-honesty checklist

- The docs keep describing 0.4.0 as the latest release until each 0.5.0 channel has been checked from what was published. That follows in a separate pull request (`docs/install.md`, `docs/python.md`, `docs/status.md`, `docs/supported-profile.md` and the README's release section).
- crates.io's trusted publisher (repository DrunkOnJava/rvt-rs, workflow `publish.yml`, environment `crates-io`) has to be in place before the tag, as `docs/maintaining.md` says; it is a registry-side setting this repository cannot check.

## Legal and contribution hygiene

N/A: release metadata only. Contributors are credited by their GitHub names in the CHANGELOG.

## Breaking changes

Listed under Motivation, with the migration for each in the CHANGELOG's **Upgrading from 0.4**.
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
…ed (#766) (#789)

## Summary

CI's tier-two job reads the BIM4LCA models its targets need, by byte range from VTT's `ARCH.zip`, so four targets that skipped in CI now run on every pull request (#766, second item).

## Motivation

Several of this month's fixes were measured on VTT's BIM4LCA example buildings (CC BY-SA 4.0). Their targets skip without `RVT_NORDIC_LCA_DIR`, which CI never set. A regression on those files would therefore pass CI, as #736 did on Snowdon. The targets are `level_parameters` (#751), `level_shared_elevation` (#752), `column_node_z` (#753) and `column_cut_body` (#757).

## Changes

- **`tools/ci/fetch-bim4lca.py`** (stdlib Python):
  - reads the archive's central directory from its last MiB;
  - for each pinned entry, reads the local header for the data offset, range-fetches the compressed bytes and inflates them as they arrive;
  - checks each file's size and sha256 against its pin.
  - A 200 answer to a range request, or an archive size other than the pinned 1,579,459,850 bytes, stops it as stale.
  - Exit codes: 0 when all files verify, 1 for a stale pin, 2 for an unreachable host after five tries.
  - `--pin` prints pin rows.
- **`research/bim4lca-models.tsv`:** the archive and five entries, 286 MB: four Revit 2024 models and Revit's IFC export of Housing_Terrain-Concrete.
- **`.github/workflows/ci.yml`**, tier-two job:
  - restores `_bim4lca` from a cache keyed on the pins file and fetches on a miss;
  - sets `RVT_NORDIC_LCA_DIR` only when all five verified;
  - reports a **NOT MEASURED** warning when the host is unreachable (the targets then skip visibly) and fails on a stale pin;
  - saves the cache from `main` only, so pull requests restore `main`'s copy rather than each storing 286 MB.
- **Docs:** `corpus/tier2/README.md`, a BIM4LCA section in `docs/reference-models.md`, and a Research entry in `CHANGELOG.md`.

## Testing

- **Pins:** the range reader's output for the five entries equals the hashes measured earlier on a full download of the archive, as recorded in `corpus/tier2/README.md`: `3df759b8…`, `c6b53726…`, `74712000…`, `23675d6c…` and the IFC's `c3946ee4…`.
- **This pull request's tier-two run** ([job 117734636435](https://github.com/DrunkOnJava/rvt-rs/actions/runs/39147646493/job/117734636435)):
  - The cache missed, as it does before `main` has saved one. The fetcher read the five files by range in about 8 seconds, `[verified]` each, and set `RVT_NORDIC_LCA_DIR`.
  - The four targets ran and passed, with no "skipping" line:
    - `column_cut_body::nordic_office_concrete_columns_stop_at_the_slab` (11.0 s)
    - `column_node_z::nordic_housing_concrete_column_z_is_revits` (8.5 s)
    - `level_shared_elevation::nordic_housing_timber_keeps_its_storeys` (1.2 s)
    - `level_parameters::nordic_housing_terrain_levels_are_revits_storeys` (2.5 s)
- After merge, `main`'s run should save the cache and later runs restore it. Checked and noted here then.

## Out of scope

- Measure integration: the BIM4LCA reference exports are 80 MB each, and #763 needs it.
- #766's R2025 item, which waits on the licence.
- The Actions cache was cleared of 1,162 unusable entries (3.6 GB) before this, so the 286 MB fits.

## Breaking changes

None.
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