Sketch fillet and chamfer: a construction line at the corner is not a side (#1026).
This commit is contained in:
1 parent
8f081679bc
commit
1337404c06
2 files changed
+34
-2
No files matched your search
@@ -488,9 +488,13 @@ fn corner(sk: &Sketch, p: &Value, cmd: &str) -> Result<(usize, usize, usize, usi
|
||||
let (la, lb) = if let Some(r) = str_(p, "point") {
|
||||
let q = sk.resolve_point(r).ok_or_else(|| bad(cmd, format!("unknown point `{r}`")))?;
|
||||
let lines: Vec<usize> = (0..sk.curves.len()).filter(|i| ends(*i).is_some_and(|(a, b)| a == q || b == q) && !sk.is_linked_curve(*i)).collect();
|
||||
match lines[..] {
|
||||
// A construction line ending there too (a diagonal that centres something) is not one of
|
||||
// the corner's sides: it keeps its end on the virtual sharp corner (#1026).
|
||||
let sides: Vec<usize> =
|
||||
if lines.len() == 2 { lines } else { lines.into_iter().filter(|i| sk.curves.get(*i).is_some_and(|c| !c.construction)).collect() };
|
||||
match sides[..] {
|
||||
[a, b] => (a, b),
|
||||
_ => return Err(bad(cmd, "the corner must join exactly two lines")),
|
||||
_ => return Err(bad(cmd, "the corner must join exactly two lines (or give the two lines as `a` and `b`)")),
|
||||
}
|
||||
} else {
|
||||
let a = str_(p, "a").and_then(|i| sk.curve_index(i)).ok_or_else(|| bad(cmd, "`a` must be a line"))?;
|
||||
|
||||
Reference in new issue
Block a user