mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-14 14:26:45 -04:00
1 parent
da8894dd08
commit
fadbea5dfe
2 files changed
+22
-1
No files matched your search
@@ -891,7 +891,10 @@ pub(crate) fn explode_kind(d: &cadcraft_doc::Drawing, e: &Entity) -> Option<Vec<
|
||||
EntityKind::Polyline3d(p) => Some(
|
||||
p.points
|
||||
.windows(2)
|
||||
.filter_map(|w| Some(Entity { handle: Handle(0), common: e.common.clone(), kind: line(w.first()?.xy(), w.get(1)?.xy()) }))
|
||||
.filter_map(|w| {
|
||||
let kind = EntityKind::Line(cadcraft_doc::Line { a: *w.first()?, b: *w.get(1)? });
|
||||
Some(Entity { handle: Handle(0), common: e.common.clone(), kind })
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
EntityKind::MText(m) => Some(
|
||||
|
||||
@@ -606,3 +606,21 @@ fn textedit_json_and_command_line() {
|
||||
assert!(s.running.is_none());
|
||||
assert!(matches!(kind(&s, &t), EntityKind::Text(x) if x.value == "hello world"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explode_polyline3d_keeps_elevations() {
|
||||
let mut s = Session::new();
|
||||
let p = h(&s.execute("3dpoly", &json!({"points": [[0, 0, 5], [1, 0, 6], [1, 1, 7]]})).unwrap());
|
||||
s.execute("explode", &json!({"handles": [p]})).unwrap();
|
||||
let lines: Vec<(f64, f64)> = s
|
||||
.doc()
|
||||
.unwrap()
|
||||
.model
|
||||
.iter()
|
||||
.filter_map(|e| match &e.kind {
|
||||
EntityKind::Line(l) => Some((l.a.z, l.b.z)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(lines, vec![(5.0, 6.0), (6.0, 7.0)]);
|
||||
}
|
||||
Reference in new issue
Block a user