Sketch Break: refuse an offset's curves, as Trim and Extend do (#8645)
An offset's ends follow its source curves on every solve, so a break's new ends were pulled back: a broken offset arc came out in three pieces going the long way round, and the solve moved curves the break never touched. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
510378d965
commit
6fa023b3ab
2 files changed
+9
-1
No files matched your search
@@ -608,6 +608,10 @@ fn break_cmd(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
doc.prune_model_params();
|
||||
return Ok(r["curves"].as_array().map(|a| a.iter().filter_map(|x| x.as_str().map(str::to_string)).collect()).unwrap_or_default());
|
||||
}
|
||||
// Its new ends would follow the source curves as trim's and extend's would: a broken
|
||||
// offset arc came out in three pieces that went the long way round, and the solve
|
||||
// moved curves the break never touched.
|
||||
refuse_offset_ends(sk, ci, "break", cmd)?;
|
||||
let sh = sk.shape(ci).ok_or_else(|| bad(cmd, "curve"))?;
|
||||
let (ts, cutters): (Vec<f64>, Vec<Option<usize>>) = if let Some(list) = &points {
|
||||
let mut v: Vec<f64> = list.iter().map(|q| sh.param(sh.project(*q))).collect();
|
||||
|
||||
@@ -2935,7 +2935,7 @@ fn trim_piece_is_what_a_trim_there_takes_away() {
|
||||
/// refused (the trim used to report success and leave the curve whole). Trimming away a whole
|
||||
/// offset curve still works, and once the association is broken the trim cuts it.
|
||||
#[test]
|
||||
fn trim_and_extend_refuse_an_offsets_ends_until_its_association_is_broken() {
|
||||
fn trim_extend_and_break_refuse_an_offsets_ends_until_its_association_is_broken() {
|
||||
let mut s = new_sketch();
|
||||
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [40, 30]}));
|
||||
let out = ids(&run(&mut s, "sketch.offset", json!({"curves": ["l1", "l2", "l3", "l4"], "distance": "2 mm", "side": [-5, -5]}))["curves"]);
|
||||
@@ -2946,6 +2946,10 @@ fn trim_and_extend_refuse_an_offsets_ends_until_its_association_is_broken() {
|
||||
assert!(e.contains("offset") && e.contains("break the offset association"), "{e}");
|
||||
let e = s.execute("sketch.extend", &json!({"curve": "l5", "at": [42, -2]})).unwrap_err().to_string();
|
||||
assert!(e.contains("offset"), "{e}");
|
||||
for params in [json!({"curve": "l5", "at": [30, -2]}), json!({"curve": "l5", "points": [[20, -2]]})] {
|
||||
let e = s.execute("sketch.break", ¶ms).unwrap_err().to_string();
|
||||
assert!(e.contains("offset") && e.contains("break the offset association"), "{params}: {e}");
|
||||
}
|
||||
assert_eq!(serde_json::to_value(sketch(&s)).unwrap(), before, "a refused trim changes nothing");
|
||||
|
||||
run(&mut s, "sketch.offset.break", json!({"curve": "l5"}));
|
||||
|
||||
Reference in new issue
Block a user