Repository navigation
feat(ifc)!: each GLB material says whether its colour and its alpha are the Revit file's or rvt-rs's (#1812) - #1818
Conversation
…le's or rvt-rs's (#1812) A consumer reading the GLB as data could not tell a colour and alpha read from the Revit material from the category palette rvt-rs draws an element with no material of its own in (translucent windows and plates, faint rooms), or from the grey of a material whose colour was not read. Every material now carries extras.colourSource, "file" or "rvt-rs". A view's visibility and graphics overrides are not read, and the support matrix says so in a new row: Revit's own IFC export ignores them too (revit-ifc BodyExporter.GetBestColourAndOpacity takes colour and opacity from the element's material, else its category's; CategoryUtil writes the surface style's transparency from the material's). probe_1812_glb_colour_sources counts a real file's materials and element primitives by source and translucency, and fails a category material not marked rvt-rs. BREAKING CHANGE: gltf::Material has a new public field, extras.
A material decoded from Global/Latest reads its colour and its transparency from two fields (elements::styling::Material::from_decoded), so a colour can be read with no transparency. Its alpha is then rvt-rs's opaque 1, and one colourSource of "file" would have told a consumer to store an opacity no file holds (rvtDevelop's read). MaterialExtras now has colourSource and alphaSource, each "file" or "rvt-rs"; the constants are SOURCE_FILE and SOURCE_RVT_RS. The probe counts materials and primitives by the pair. The support matrix also says the IFC writes transparency 0 where none was read.
|
Measure 43291027145 at
Across all 100 models, every material is |
…ostics moved, the scorer residue, the probe's lines and the timing ratios (#1830) ## Summary Measure's run summary now opens with its verdict, so its reader no longer downloads both sides' results to learn which exports moved: - how many models' `ifc.sha256` and `diagnostics.json` equal the base's, naming the ones that differ (the scorer diff leaves both files out); - whether the scorer diff holds anything beyond what the head side alone writes (each model's `probe.txt`, its `probe: exit N` line, and `areas_across_saves*`), with the first such lines; - with a probe, its lines counted across the models, and any model whose probe did not exit 0. A timed run opens its timing table with a timing verdict: - the median, lowest and highest head / base time and peak, for the models, the samples of Revit 2023 to 2027 and those of 2015 to 2022; - the three longest-running files and the three with the highest peak; - every file more than 3% slower, or more than 2% higher in peak. Both are also in the job log and in small artifacts (`measure-verdict`, and `timing-verdict.md` in `measure-timing`), for a reader without the summary page. ## Motivation Every Measure run is read for the same figures, and they were computed by hand each time: five times on 11-12 alone (#1813, #1818, #1821, #1823 and the 0.14.1 hotfix). Neither script judges a pull request's registered rows. They print what the rows are written in. ## Changes - `tools/re/measure_verdict.py`: the export verdict over the merged `measure-head` and `measure-base` directories and `scorer-diff.txt`. - `tools/re/timing_verdict.py`: the timing verdict over the merged `timing.md`. It computes each ratio from the medians, not from the table's rounded ratio column. - `.github/workflows/measure.yml`: - the compare job checks the first script out with its other tools, makes the scorer diff before the summary, prints the verdict at its top, and uploads `measure-verdict`; - the timing job checks the second script out first and prints its verdict above the table. ## Testing Unit tests are banned here. Both scripts were run on the results of real runs and compared with what had been read by hand: - **#1821's run 43291861101:** 125 of 125 exports and 101 of 101 diagnostics identical, no scorer residue, and the probe's `export units_reads held=0 walked=1` on 100 models and `held=1` on one. This is the read that found #1821's dropped pass. - **#1694's C2 timing, 43288830617:** the 28 samples of Revit 2023 to 2027 at a median of 0.998, `rac_basic` 2023 at 1.070 and 2027 at 1.050, and 2021 `rst_basic`'s peak at 1.023. These match comment 6834180051. - **A scorer diff with two added lines and an extra file:** reported as 3 lines in 2 files, with the head-only output still left out. - **No base, a missing head and a missing table:** each prints a plain line and does not fail the job. The rehearsal is run [43304266907](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43304266907), dispatched from this branch on two models, timed, with a probe. Its summary, job logs and both artifacts are read before this is marked ready. `tools/ci/check-workflows.py`: 0 errors, 0 warnings. ## Breaking changes None.
… instead of writing it opaque (#1820) (#1826) ## Summary An IFC surface style no longer writes a transparency of 0, fully opaque, for a material whose colour was read but whose transparency was not. `IfcSurfaceStyleRendering.Transparency` is optional in IFC4, so it is now left unset (`$`). Closes #1820. ## Motivation A material decoded from `Global/Latest` reads its colour and its transparency from two separate fields (`elements::styling::Material::from_decoded`), so the colour can be read without the transparency. `step_writer` then wrote `mat.transparency.unwrap_or(0.0)`, a value no file gave. Revit's own export writes the material's own transparency (revit-ifc `CategoryUtil`). #1818 marks the same case `alphaSource: "rvt-rs"` in the GLB, and this PR makes the IFC fail closed on it. ## Changes - `src/ifc/step_writer.rs`, the material loop: an unread transparency is written `$`, and a read one as before (`{:.6}`). - `changelog.d/fixed/1820-unread-transparency.md`. ## Testing Unit tests are banned here. The evidence is one Measure run. **The count first.** #1818's probe marks each GLB material `file` or `rvt-rs` for its colour and its alpha. A model material is marked `file/rvt-rs` exactly when its colour was read and its transparency was not, which is the case this PR changes. Run [43291027145](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43291027145) found no such material on any of the 100 models whose probe output it keeps (#1818, comment 6834758003). Its six `racadv` shards and the held-out models were not counted. Rows, registered before the run, for one unfiltered Measure of this head against `main`. It covers the samples of every year, the BIM4LCA models, the R2025 set, `rac_advanced` and the held-out models: 1. **Unchanged where the transparency was read.** On every model, `ifc.sha256` and every scorer file equal `main`'s, or the only lines that differ are `IFCSURFACESTYLERENDERING` lines whose second attribute goes from `0.000000` to `$`. A model where an export moves is counted, and named unless it is held out, with how many lines moved. That count completes #1820's. 2. **The colour scorer holds.** `material_colours_vs_ifc` is unchanged on every model. It reads `Transparency or 0`, so an unset value scores as the 0 it replaces. This row checks that the scorer still reads the file. - [x] `rustfmt --edition 2024 --check` passes. CI runs the rest of the gate. **Result**, Measure [43298971854](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43298971854), `7f825b2c` against `main` at `eaf22753`. It covered the samples of every year, the BIM4LCA offices and housing, the R2025 set, `rac_advanced` and the held-out models (counts only for the held-out ones): 1. **Holds, with no line moved.** 125 of 125 `ifc.sha256` and 101 of 101 `diagnostics.json` equal `main`'s. No measured model has a material whose colour is read and whose transparency is not, so #1820's count is 0 on the measured corpus. The change is exercised only by the synthetic project, whose concrete now has no transparency read; CI validates its surface style there. 2. **Holds.** The scorer diff holds only output that the head alone writes: probe output and `areas_across_saves*`. `material_colours_vs_ifc` is unchanged on every model. Since that run, the branch has had a clean merge of `main` (`75a4b423`), the support-matrix line (`b2dbabe7`) and the synthetic fixture's assertions (`d7f740f0`). No export path changed, so the run carries. - [x] Verified end to end on real Revit files: the Measure run above. - [x] If this touches the IFC exporter: Core Interior's witness observations change only if one of its materials is read this way, and row 1 says whether one is. - N/A: not a performance change. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR - [x] A user-visible change has its entry as a fragment under `changelog.d/<section>/` - [x] If a limitation was resolved, the relevant docs are updated. The support-matrix note #1818 adds ("the IFC writes transparency 0 where none was read") is updated here once #1818 lands, whichever lands first. - [x] If a new limitation was introduced, it is documented: none - [x] Commit messages describe WHAT changed and WHY - [x] No emojis in code, docs, or commit messages - [x] No private paths, personal email addresses, or internal jargon in committed files - N/A: not a reverse-engineering finding ## Legal and contribution hygiene - [x] I agree this work is licensable under Apache-2.0 - [x] This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content. revit-ifc is cited by file and class only. - [x] No new test fixtures ## Breaking changes None to the API. An IFC consumer that required `Transparency` to be set gets `$` for a material whose transparency rvt-rs did not read. No measured model has one (row 1). ## Screenshots or output samples Before: `#46=IFCSURFACESTYLERENDERING(#45,0.000000,$,$,$,$,$,$,.FLAT.);`. After, for a material with no transparency read: `#46=IFCSURFACESTYLERENDERING(#45,$,$,$,$,$,$,$,.FLAT.);`.
… takes their alpha (#1812) (#2109) ## Summary A body the glTF exporter draws **whole**, the shared box or its own mesh, in its category's colour, now takes the alpha of its materials where every one of them is transparent: on the open models, `rac_basic`'s 8 water glasses on each of its 13 saves. A door, lamp or window with a glass part stays as on `main`, since which part of a saved mesh is the glass is not read. Before, such a body kept the category's alpha, so the transparency of its own materials was lost. @zenglanmu's Revit 2024 project showed it: by their count, 17 glass doors and 149 glass light fixtures drawn opaque in the GLB. #1818 fixed the *emission* of material alpha and added `extras.alphaSource`; the element-to-material selection for whole bodies still fell back to the category material. #1603 (missing materials on 2015 to 2023 family instances) is separate and not addressed here. **The rule, after review** ([Griffin's call](#2109 (comment))): a body drawn whole in its category's colour takes the alpha of its materials only where it reads at least one and every one is read as transparent, and then the least transparent one's, so no part is drawn fainter than it is (`all_transparent_alpha`). The materials are its constituent set (several materials, or one whose colour was not read), a single-profile set whose colour was not read, or a layer set it is not drawn in. A body that also holds an opaque material, a material whose transparency was not read or lies outside 0 to 1, or a layer or index that names no material, keeps its category's alpha. Drawn at its glass's alpha, a door with a glass panel would look all glass, and which part of a saved mesh is the glass is not read (#2112). - Windows, curtain panels and rooms keep their translucent category colour as on `main`. - A see-through body's material is `Category <class> transparent`, `BLEND` and double-sided, with `colourSource` `"rvt-rs"` and `alphaSource` `"file"`: its alpha is one minus a Revit material's own transparency. `MaterialExtras` and `docs/viewer-api.md` say so. - A body that keeps its category's alpha shares the category's one material, as on `main`. Geometry, the IFC export and `diagnostics.json` are unchanged. Original change by @zenglanmu (`5686cddd`, re-signed with their authorship); the rule above, the docs and the tests by the maintainer on review (`fef2b7ad`). ## Testing - Six tests of `all_transparent_alpha`'s failure modes in `src/ifc/gltf.rs` (no material; a transparency not read; an opaque frame beside glass; differing transparencies; a transparency outside 0 to 1, NaN or infinite; one fully transparent material). It is a pure helper, the one kind of unit test this repository takes; they run in CI's fast run on `fef2b7ad`, which is green. The hand-built-model test first proposed is removed. - Measured on every open model, against [the rows](#2109 (comment)), all of which hold ([the reading](#2109 (comment))): the Measure ([44756684505](https://github.com/DrunkOnJava/rvt-rs/actions/runs/44756684505)) finds all 120 exports and 102 `diagnostics.json` identical and no scorer line moving; `probe_2109_whole_body_alpha` on this head and on `main` ([44756695010](https://github.com/DrunkOnJava/rvt-rs/actions/runs/44756695010), [44756704637](https://github.com/DrunkOnJava/rvt-rs/actions/runs/44756704637)) finds 104 `IfcBuildingElementProxy` on `rac_basic`'s 13 saves newly see-through (16 at alpha 0.05, 88 at 0.15), no other class, windows, curtain panels and rooms as on `main`, and no category material written twice. ## Evidence boundary The Revit 2024 project that exposed this is not redistributable. Which elements the rule reaches on the open models is the probe's count above: on @zenglanmu's project, the glass doors and fixtures stay opaque unless every material they read is transparent, so a downstream patch carrying the first rule still differs from this. --------- Co-authored-by: zenglanmu <[email protected]> Co-authored-by: Griffin Long <[email protected]>
Summary
Each GLB material now carries
extras.colourSourceandextras.alphaSource, each:"file"where the value is the Revit material's own (the alpha being one minus its transparency);"rvt-rs"where rvt-rs chose it.The second covers the category palette an element with no material of its own is drawn in, translucent windows and plates and faint rooms included, the mid-grey of a material whose colour was not read, and the opaque alpha of one whose transparency was not read.
The two are marked apart because a material decoded from
Global/Latestreads its colour and its transparency from two fields (elements::styling::Material::from_decoded), so a colour can be read with no transparency. rvtDevelop found this in the first read;50fcbbc1splits the mark.A view's visibility and graphics overrides are not read. A new support-matrix row says so, and gives the reason: Revit's own IFC export ignores them too.
Motivation
#1812, from a downstream CAD viewer that stores the GLB's colour and opacity as entity data. It could not tell "Revit says 45% opaque" from "rvt-rs chose 45% for windows".
The
Category …material name does not settle it: a Revit material can be named anything.On view overrides, Autodesk's open-source exporter (
revit-ifc, source 5 of CLEANROOM.md) never reads them:BodyExporter.GetBestColourAndOpacitytakes an element's colour and opacity from its material, or else from its category's material;CategoryUtilwritesIfcSurfaceStyleRendering.Transparencyfrom the material's own transparency.rvt-rs follows Revit's export, so overrides stay outside the contract, now stated.
Changes
src/ifc/gltf.rs:Material.extras: Option<MaterialExtras>, serialized as glTF materialextras;MaterialExtras { colour_source, alpha_source }, eachSOURCE_FILEorSOURCE_RVT_RS;"file"when its colour was read, and its alpha when its transparency was;"file"for both (the band carries both from the material's appearance);"rvt-rs"for both.docs/viewer-api.md: the marker, what each value covers, and the view-override boundary with its revit-ifc citation.docs/support-matrix.json: new rowview-graphics-overrides,unsupported.probes/examples/probe_1812_glb_colour_sources.rs:rvt-gltfmakes with no flags;"rvt-rs".changelog.d/changed/1812-glb-colour-source.md.Nothing else in the GLB changes: colours, alphas, names, nodes and meshes are as before. The IFC writer is untouched (
category_colouris used only by the GLB).Testing
Unit tests are banned here. The evidence is one Measure run of this head against
main, unfiltered, with the samples, the BIM4LCA models and the R2025 set, and the probe on every model. Rows, registered before the run is read:ifc.sha256and every scorer file, the GLB scorers included, equalsmain's.failures unmarked=0 category_not_rvt_rs=0.rmeadvancedsampleproject(the issue's file), every translucent material is eitherfile/fileor aCategory …one (IFCWINDOW,IFCPLATEorIFCSPACE,rvt-rs/rvt-rs): a translucent alpha comes only from a read transparency or from the palette. Run 43291027145 at50fcbbc1; the counts are in a comment below. (The first run, atfbf3fa16, was cancelled when the mark was split.)tools/check-local.sh: CI is the compiler for this repository; the draft runs fast CI.Audit-honesty checklist
changelog.d/changed/probes/examples/Legal and contribution hygiene
Breaking changes
gltf::Materialhas a new public field,extras. Code that builds aMaterialwith a struct literal addsextras: None, or the mark it means.Screenshots or output samples
The probe's output on the issue's file is posted with the Measure run.