diff --git a/crates/geom/src/brep/history.rs b/crates/geom/src/brep/history.rs index b098fc09c..95533c276 100644 --- a/crates/geom/src/brep/history.rs +++ b/crates/geom/src/brep/history.rs @@ -119,7 +119,8 @@ pub enum EdgeOrigin { } /// A result edge: the result faces it separates and what it came from (empty when it is new -/// and lies between faces new to the operation). +/// and lies between faces new to the operation, or between two pieces of one face: a split +/// line). #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EdgeProv { pub faces: Vec, diff --git a/crates/smlib/src/history.rs b/crates/smlib/src/history.rs index b88b54d12..e2eedc164 100644 --- a/crates/smlib/src/history.rs +++ b/crates/smlib/src/history.rs @@ -178,10 +178,11 @@ impl Raw { } }; let origins = if e.origins.is_empty() { - // New: where its two faces meet, each side what that face came from. + // New: where its two faces meet, each side what that face came from. Between two + // pieces of one face (a split line) nothing met: it comes from nothing. let side = |f: usize| faces.get(f).and_then(|p| Side::new(p.origins.iter().copied())); match bounds.as_slice() { - [a, b] => side(*a).zip(side(*b)).map(|(a, b)| EdgeOrigin::meet(a, b)).into_iter().collect(), + [a, b] => side(*a).zip(side(*b)).filter(|(a, b)| a != b).map(|(a, b)| EdgeOrigin::meet(a, b)).into_iter().collect(), _ => Vec::new(), } } else { diff --git a/crates/smlib/src/history/tests.rs b/crates/smlib/src/history/tests.rs index 6fdc4b994..7282aa61d 100644 --- a/crates/smlib/src/history/tests.rs +++ b/crates/smlib/src/history/tests.rs @@ -55,6 +55,17 @@ fn new_edges_are_where_their_faces_meet() { h.check_counts((3, 3), &[(3, 8), (5, 4)]).unwrap(); } +/// A face split in two (a split line across operand 0's face 0): the new edge lies between two +/// pieces of one face, where nothing met, so it comes from nothing. +#[test] +fn a_split_line_comes_from_nothing() { + let raw = Raw::decode(&[1, 2, 1, 2, 1, 0, 0, 2, 1, 0, 0, 2, 0, 1, 0]).unwrap(); + let h = raw.history(&[Order::default()], &Order::default()).unwrap(); + assert_eq!(h.faces.iter().map(|f| (f.origins.clone(), f.change)).collect::>(), vec![(vec![face(0, 0)], Change::Split); 2]); + assert_eq!(h.edges[0].faces, vec![0, 1]); + assert!(h.edges[0].origins.is_empty(), "{:?}", h.edges[0].origins); +} + #[test] fn renumbers_into_canonical_order() { let raw = Raw::decode(RECORDS).unwrap();