forked from 1b-agent/opencadstudio-upstream
Use modeler region bounds in automation queries and filters
This commit is contained in:
1 parent
b42ae9d4a8
commit
974d5997d0
2 files changed
+8
-14
No files matched your search
+7
-13
@@ -213,14 +213,8 @@ fn entity_json(e: &acadrust::EntityType, detail: &str) -> Value {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
if detail == "full" {
|
if detail == "full" {
|
||||||
let bounds = e.as_entity().bounding_box();
|
let (min, max) = crate::scene::convert::tess::entity_bounds(e);
|
||||||
map.insert(
|
map.insert("bounds".into(), json!({ "min": min, "max": max }));
|
||||||
"bounds".into(),
|
|
||||||
json!({
|
|
||||||
"min":[bounds.min.x,bounds.min.y,bounds.min.z],
|
|
||||||
"max":[bounds.max.x,bounds.max.y,bounds.max.z]
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if let Ok(Value::Object(wrapper)) = serde_json::to_value(e) {
|
if let Ok(Value::Object(wrapper)) = serde_json::to_value(e) {
|
||||||
if let Some((_, properties)) = wrapper.into_iter().next() {
|
if let Some((_, properties)) = wrapper.into_iter().next() {
|
||||||
map.insert("properties".into(), properties);
|
map.insert("properties".into(), properties);
|
||||||
@@ -652,11 +646,11 @@ impl OpenCADStudio {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(bounds) = bounds {
|
if let Some(bounds) = bounds {
|
||||||
let entity_bounds = e.as_entity().bounding_box();
|
let (min, max) = crate::scene::convert::tess::entity_bounds(e);
|
||||||
if entity_bounds.max.x < bounds[0]
|
if max[0] < bounds[0]
|
||||||
|| entity_bounds.max.y < bounds[1]
|
|| max[1] < bounds[1]
|
||||||
|| entity_bounds.min.x > bounds[2]
|
|| min[0] > bounds[2]
|
||||||
|| entity_bounds.min.y > bounds[3]
|
|| min[1] > bounds[3]
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1718,7 +1718,7 @@ pub(crate) fn set_wire_aabb(w: &mut WireModel, entity_box: [f32; 4]) {
|
|||||||
w.aabb = out;
|
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 let acadrust::EntityType::Region(region) = e {
|
||||||
if region.wires.is_empty() {
|
if region.wires.is_empty() {
|
||||||
if let Some(bounds) = super::solid3d_tess::kernel_region_body(region)
|
if let Some(bounds) = super::solid3d_tess::kernel_region_body(region)
|
||||||
|
|||||||
Reference in new issue
Block a user