Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.d/research/saved-rendered-assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- **Rendered family assets in Saved graphics (experimental).** A research
reader can select typed render-library meshes stored under a display filter
in a family symbol. Existing visibility and detail selection applies. The
reader validates the authored facets and places them in the symbol's frame.
The normal Saved reader keeps its previous graph projection and light-source
exclusions.
167 changes: 167 additions & 0 deletions probes/examples/probe_rendered_saved_assets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//! Inspect selected owners' Saved geometry in Fine detail. Set
//! RVT_RESEARCH_RENDERED_ASSETS=1 only for the candidate arm.
//! The optional --mesh flag emits the original indexed facets and placement.

use anyhow::{Context, Result, ensure};
use rvt::control::WalkerControl;
use rvt::research::{native_document::Options, native_saved_scene};
use sha2::{Digest, Sha256};
use std::collections::BTreeSet;
use std::path::PathBuf;

fn main() -> Result<()> {
let mut args = std::env::args_os().skip(1);
let input = args.next().context("expected MODEL.rvt or --check")?;
if input == "--check" {
return check_contract();
}
let input = PathBuf::from(input);
let mut emit_mesh = false;
let mut selected_ids = BTreeSet::new();
for arg in args {
if arg == "--mesh" {
emit_mesh = true;
} else {
let id = arg
.to_str()
.context("expected a numeric element ID")?
.parse()?;
selected_ids.insert(id);
}
}
ensure!(!selected_ids.is_empty(), "expected at least one element ID");
let expected_ids = selected_ids.clone();
let options = Options {
selected_ids,
max_graph_values: 2_000_000,
..Options::default()
};
let mut file =
rvt::RevitFile::open_with_limits(input, rvt::cli::open_limits(None, None, true))?;
let mut found = BTreeSet::new();
native_saved_scene::extract_in_batches_with_control(
&mut file,
&options,
3,
&WalkerControl::default(),
|element| {
ensure!(found.insert(element.id), "duplicate owner");
let primitives = element
.meshes
.primitives
.iter()
.filter(|primitive| !primitive.hidden && !primitive.filtered);
let mut digest = Sha256::new();
let mut triangles = 0;
let mut vertices = Vec::new();
let mut indices = Vec::new();
for primitive in primitives {
digest.update(serde_json::to_vec(primitive)?);
triangles += primitive.triangles.len();
if emit_mesh {
let offset = u32::try_from(vertices.len())?;
vertices.extend_from_slice(&primitive.vertices);
indices.extend(
primitive
.triangles
.iter()
.map(|triangle| triangle.map(|i| i + offset)),
);
}
}
let mut row = serde_json::json!({
"id": element.id,
"status": element.status,
"diagnostics": element.meshes.diagnostics,
"unbounded": element.meshes.unbounded_faces,
"triangles": triangles,
"geometryHash": digest.finalize().iter().map(|byte| format!("{byte:02x}")).collect::<String>(),
});
if emit_mesh {
row["mesh"] = serde_json::json!({"vertices": vertices, "triangles": indices});
}
println!("{row}");
Ok(())
},
)?;
ensure!(found == expected_ids, "missing or unexpected owners");
Ok(())
}

fn check_contract() -> Result<()> {
use rvt::research::native_graphics_traversal::select_graphics_with_resolver_at_detail;
use rvt::research::native_parameters::ObjectGraph;
use serde_json::json;

let pointer = |id: u32| json!({"pointer_token": id, "offset": id, "class_tag": id});
let node = |id, class, fields| {
json!({
"class_tag": id, "class_name": class, "token": id,
"start": 0, "fields_end": 0, "fields": fields,
})
};
let edge = |source, target| {
json!({
"source_object_index": source, "pointer_offset": target,
"pointer_token": target, "target_object_index": target, "target_class_tag": target,
})
};
let graph = |asset_type: u32, nonempty, topology: &'static str, flags| -> Result<ObjectGraph> {
let faces = if nonempty { vec![pointer(4)] } else { vec![] };
Ok(serde_json::from_value(json!({
"consumed_bytes": 0,
"objects": [
node(0, "GFilter", json!({
"m_subNodes": [pointer(1), pointer(2), pointer(3)], "m_oConditions": [pointer(4)],
"m_bIsNestedDetailFamily": false, "m_GInfo": {"m_flags": flags},
})),
node(1, "GImposter", json!({"m_oAsset": pointer(5)})),
node(2, "GPolyMesh", json!({"m_pFacetedTopology": pointer(6)})),
node(3, "Geometry", json!({"m_pFaces": faces, "m_pEdges": []})),
node(4, "GConditionInt", json!({"m_param": 3, "m_comp": 0, "m_value": 1})),
node(5, "Asset", json!({"m_eAssetType": asset_type, "m_sName": "generated asset"})),
node(6, topology, json!({})),
],
"edges": [edge(0, 1), edge(0, 2), edge(0, 3), edge(0, 4), edge(1, 5), edge(2, 6)],
}))?)
};
let select = |graph: &ObjectGraph, detail| {
select_graphics_with_resolver_at_detail(graph, &|_| None, detail)
};
let asset = graph(5, false, "FacetedTopology8", 0)?;
let enabled =
std::env::var_os("RVT_RESEARCH_RENDERED_ASSETS").is_some_and(|value| value == "1");
let fine = select(&asset, 3);
ensure!(
fine.diagnostics.is_empty() && fine.selected.len() == usize::from(enabled),
"Fine asset selection"
);
if enabled {
ensure!(
fine.selected[0].object_index == 2,
"unexpected selected carrier"
);
}
let coarse = select(&asset, 1);
ensure!(
coarse.diagnostics.is_empty() && coarse.selected.is_empty(),
"Coarse exclusion"
);
for excluded in [
graph(3, false, "FacetedTopology8", 0)?,
graph(5, true, "FacetedTopology8", 0)?,
graph(5, false, "FacetedTopology0", 0)?,
graph(5, false, "FacetedTopology8", 0xe0)?,
] {
let selection = select(&excluded, 3);
ensure!(
selection.diagnostics.is_empty() && selection.selected.is_empty(),
"noneligible branch admitted"
);
}
println!(
"{}",
json!({"renderedAssets":enabled, "selectionContract":"passed"})
);
Ok(())
}
164 changes: 164 additions & 0 deletions research/rendered-saved-assets-cohorts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
[
{
"name": "2024-snowdon_towers_sample_architectural",
"sha256": "33271010919acb2a0d0d040851393a511d86ea7fd9a1f4c054797ae03e5e44a1",
"ids": [
1233135,
1233374,
1233380,
1233388,
1233396,
1233404,
1233412,
1233420,
1233428,
1233438,
1239522,
1239582,
1394649,
1394650,
1394651,
1394652,
1410527,
1410528,
1410530,
1410531,
1410532,
1410533,
1410534,
1410535,
1410536,
1410537,
1410538,
1410539,
1410540,
1410541,
1410542,
1410543,
1410642,
1410707,
1410708,
1410770,
1410843,
1410844,
1410852,
1410853,
1410912,
1410913,
1410932,
1410933,
1410960,
1410961,
1411112,
1411160,
1411166,
1411167,
1411169,
1411170,
1411172,
1411173,
1411174,
1411175,
1411177,
1411178,
1411758,
1411936,
1411937,
1411938,
1411939,
1411940,
1411941,
1411942,
1411943,
1411944,
1411945,
1411946,
1411947,
1411948,
1411949,
1411950,
1411951,
1412389,
1412390,
1412391,
1412448,
1415392,
1415394,
1415395,
1415396,
1415397,
1415398,
1415399,
1428699,
1500975,
1501075,
1612921,
1613008,
1613310,
2006571,
2006793,
2006856,
2007014,
2012668,
2044297,
2044298,
2044299,
2044300,
2044301,
2044302,
2044303,
2044304,
2044306,
2044307,
2044308,
2044309,
2044310,
2044311,
2044312,
2044313,
2046318,
2046326,
2047922,
2047962,
2048010,
2048148,
2048194,
2048270,
2048333,
2048414,
2048470,
2158155,
2158307,
2158407
],
"triangles": 60195
},
{
"name": "2024-racbasicsampleproject",
"sha256": "bb62c161b7991f0c5ec76605d3d9d0407e04001a2e4e6acac1c7fc32fd45ee55",
"ids": [
946164,
946385,
946484,
946631,
946708,
946759,
946816,
946835,
946912,
946949,
947002,
947057,
947108,
947273,
947330,
947379,
950367,
954641,
954779,
954992,
955125
],
"triangles": 11997
}
]
7 changes: 3 additions & 4 deletions src/ifc/saved_meshes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,9 @@ pub fn attach_scoped_with_limits_and_control(

/// Attach Saved meshes with an explicit experimental recovery policy.
/// Available with `unstable-research`. The policy overrides the five Hermite
/// trim and shared-edge environment switches and `RVT_AGREEING_STRIP_PLAN`
/// on the threads doing the meshing. Only
/// [`SavedMeshRecovery::SharedBoundaryWithAgreeingStrip`] enables the strip
/// planner for an explicit request.
/// trim and shared-edge environment switches, `RVT_AGREEING_STRIP_PLAN`,
/// and `RVT_RESEARCH_RENDERED_ASSETS`. For explicit requests, the strip planner
/// and rendered asset selection are enabled by their respective policy variants.
/// Graph limits, cancellation, progress reporting, and other meshing controls
/// work as in [`attach_scoped_with_limits_and_control`].
#[cfg(feature = "unstable-research")]
Expand Down
Loading