From 974d5997d026cc2b1266563219c17a0dbbcc0926 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Fri, 11 Sep 2026 13:08:08 +0300 Subject: [PATCH] Use modeler region bounds in automation queries and filters --- src/app/automation.rs | 20 +++++++------------- src/scene/convert/tess.rs | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/app/automation.rs b/src/app/automation.rs index b6038532a..440d3b76a 100644 --- a/src/app/automation.rs +++ b/src/app/automation.rs @@ -213,14 +213,8 @@ fn entity_json(e: &acadrust::EntityType, detail: &str) -> Value { _ => {} } if detail == "full" { - let bounds = e.as_entity().bounding_box(); - map.insert( - "bounds".into(), - json!({ - "min":[bounds.min.x,bounds.min.y,bounds.min.z], - "max":[bounds.max.x,bounds.max.y,bounds.max.z] - }), - ); + let (min, max) = crate::scene::convert::tess::entity_bounds(e); + map.insert("bounds".into(), json!({ "min": min, "max": max })); if let Ok(Value::Object(wrapper)) = serde_json::to_value(e) { if let Some((_, properties)) = wrapper.into_iter().next() { map.insert("properties".into(), properties); @@ -652,11 +646,11 @@ impl OpenCADStudio { continue; } if let Some(bounds) = bounds { - let entity_bounds = e.as_entity().bounding_box(); - if entity_bounds.max.x < bounds[0] - || entity_bounds.max.y < bounds[1] - || entity_bounds.min.x > bounds[2] - || entity_bounds.min.y > bounds[3] + let (min, max) = crate::scene::convert::tess::entity_bounds(e); + if max[0] < bounds[0] + || max[1] < bounds[1] + || min[0] > bounds[2] + || min[1] > bounds[3] { continue; } diff --git a/src/scene/convert/tess.rs b/src/scene/convert/tess.rs index 18e3d3123..96257ed55 100644 --- a/src/scene/convert/tess.rs +++ b/src/scene/convert/tess.rs @@ -1718,7 +1718,7 @@ pub(crate) fn set_wire_aabb(w: &mut WireModel, entity_box: [f32; 4]) { w.aabb = out; } -fn entity_bounds(e: &acadrust::EntityType) -> ([f64; 3], [f64; 3]) { +pub(crate) fn entity_bounds(e: &acadrust::EntityType) -> ([f64; 3], [f64; 3]) { if let acadrust::EntityType::Region(region) = e { if region.wires.is_empty() { if let Some(bounds) = super::solid3d_tess::kernel_region_body(region)