Planar source matching looks only at planes with the same normal (#917)
Body::with_planar_sources compared every planar face of a result with every unsourced planar face of its inputs, so a boolean on an import with a few thousand facets ran out of its comparison budget before it started. The lists are now sorted by normal x and each face only compares with entries inside a narrow normal window found by binary search; the exact same_support test and the work budget are unchanged. Adds an engine test joining a pin onto a 4000-sided imported prism.
This commit is contained in:
1 parent
2eb292dd4a
commit
7da7bbb335
2 files changed
+58
-10
No files matched your search
@@ -959,6 +959,36 @@ fn step_open_then_model_on_it() {
|
||||
assert!(rel(volume(&mut s2), before) < 1e-6);
|
||||
}
|
||||
|
||||
/// A join onto an imported body of thousands of planar faces (a converted mesh, say): each face of
|
||||
/// the result was compared with every planar face of the inputs whose source is unknown, and the
|
||||
/// join was refused past the comparison budget.
|
||||
#[test]
|
||||
fn join_onto_a_finely_faceted_import() {
|
||||
let dir = std::env::temp_dir().join(format!("solidcraft-step-faceted-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let n = 4000;
|
||||
let mut pts: Vec<[f64; 2]> =
|
||||
(0..n).map(|i| std::f64::consts::TAU * f64::from(i) / f64::from(n)).map(|a| [20.0 * a.cos(), 20.0 * a.sin()]).collect();
|
||||
pts.push(pts[0]);
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "sketch.create", json!({"plane": "XY", "name": "P"}));
|
||||
run(&mut s, "sketch.line", json!({"points": pts}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "solid.extrude", json!({"sketch": "P", "distance": 10}));
|
||||
let p = dir.join("Faceted.step");
|
||||
run(&mut s, "file.export", json!({"path": p.to_string_lossy()}));
|
||||
let prism = volume(&mut s);
|
||||
|
||||
let mut d = Session::default();
|
||||
run(&mut d, "file.insert_step", json!({"path": p.to_string_lossy()}));
|
||||
run(&mut d, "sketch.create", json!({"plane": "XY", "name": "Pin"}));
|
||||
run(&mut d, "sketch.rectangle.two_point", json!({"p0": [-5, -5], "p1": [5, 5]}));
|
||||
run(&mut d, "sketch.finish", json!({}));
|
||||
run(&mut d, "solid.extrude", json!({"sketch": "Pin", "distance": 25, "operation": "join"}));
|
||||
assert_eq!(d.model.state().bodies.len(), 1);
|
||||
assert!(rel(volume(&mut d), prism + 10.0 * 10.0 * 15.0) < 1e-6, "{}", volume(&mut d));
|
||||
}
|
||||
|
||||
/// Shell an imported body; insert STEP into an existing design; extension case; bad files.
|
||||
#[test]
|
||||
fn step_insert_shell_and_errors() {
|
||||
|
||||
Reference in new issue
Block a user