ifc_lite_processing/
product_geometry_audit.rs1use std::{collections::BTreeMap, sync::{Arc, Mutex}};
4use crate::element::ProducedElementMeshes;
5
6#[derive(Clone, Default)]
11pub struct ProductGeometryAudit {
12 receipts: Arc<Mutex<BTreeMap<u32, Result<(), String>>>>,
13}
14
15impl ProductGeometryAudit {
16 pub fn require_complete(&self, product_id: u32) -> Result<(), String> {
21 self.receipts.lock().unwrap_or_else(|e| e.into_inner()).get(&product_id)
22 .cloned().unwrap_or_else(|| Err("no completed processing receipt".into()))
23 .map_err(|reason| format!("incomplete product #{product_id}: {reason}"))
24 }
25
26 pub(crate) fn record(
27 &self, id: u32, produced: &ProducedElementMeshes,
28 decoder: &ifc_lite_core::EntityDecoder,
29 unsupported: &rustc_hash::FxHashMap<String, u64>,
30 ) {
31 let mut reasons = Vec::new();
32 if !unsupported.is_empty() { reasons.push(format!("dropped representation items: {}", ifc_lite_geometry::format_unsupported_breakdown(unsupported))); }
33 if decoder.refused_records() > 0 { reasons.push("refused geometry input".into()); }
34 if produced.csg_failures.values().any(|failures| !failures.is_empty()) { reasons.push("CSG diagnostic/fallback".into()); }
35 if produced.degenerate_triangles_dropped > 0 { reasons.push("degenerate triangles dropped".into()); }
36 if produced.meshes.is_empty() { reasons.push("no mesh output".into()); }
37 let receipt = if reasons.is_empty() { Ok(()) } else { Err(reasons.join("; ")) };
38 self.receipts.lock().unwrap_or_else(|e| e.into_inner()).insert(id, receipt);
39 }
40}