diff --git a/crates/difftest/src/units/boolean_merge_p2.rs b/crates/difftest/src/units/boolean_merge_p2.rs index e91cd66c7..a997b105f 100644 --- a/crates/difftest/src/units/boolean_merge_p2.rs +++ b/crates/difftest/src/units/boolean_merge_p2.rs @@ -32,6 +32,7 @@ use solidcore::geom::object::{NotifyOperation, ObjectRef}; use solidcore::heal::stitch::p1::{DefaultStitchCallback, Stitch}; use solidcore::kernel::Kernel; use solidcore::topology; +use solidcore::topology::brep_cache::{arena_identity, CacheObject}; use solidcore::topology::topology::Topology; use solidcore::topology::topology_traverser::Marks; use solidcore::topology::{ @@ -637,6 +638,14 @@ fn run_rust(i: &Inputs, p: &Prepared) -> Result { let edge_dest = |e: EdgeId| key(2_000_000, edge::TYPE, e.index()); let face_source = |f: FaceId| key(5_000_000, face::p2::TYPE, f.index()); let face_dest = |f: FaceId| key(4_000_000, face::p2::TYPE, f.index()); + // The operands' edges and faces own their curves and surfaces under these + // names, as the library names them (`MakeFace`'s infinite-region rays solve + // on a B-rep cache whose trees hold only geometry owned under them). + let brep = Some(arena_identity(CacheObject::Brep)); + crate::util::own_edge_curves(&mut a, &edge_dest, brep); + crate::util::own_face_surfaces(&mut a, &face_dest); + crate::util::own_edge_curves(b, &edge_source, brep); + crate::util::own_face_surfaces(b, &face_source); let mut copy = TopologyCopy { vertices: VertexCopy { records: &mut records, diff --git a/crates/difftest/src/units/topology_brep_p6.rs b/crates/difftest/src/units/topology_brep_p6.rs index 0695002e8..cc26783f3 100644 --- a/crates/difftest/src/units/topology_brep_p6.rs +++ b/crates/difftest/src/units/topology_brep_p6.rs @@ -927,6 +927,11 @@ fn make_faces_rust(i: &Inputs) -> Result { counts(&fixture.graph).ok_or_else(|| harness("fixture construction failed"))?; let (mut b, _) = shared::import(&fixture.graph)?; b.set_key(ObjectKey(0xB000_0000)); + // The fixture's edges own their curves, as its faces own their surfaces (the import + // gives those the face names of `key_of`). The ray fires of the infinite-region + // search find an edge from its curve's owner, under the runner's names. + let brep = solidcore::topology::brep::p2::brep_ref(&b); + crate::util::own_edge_curves(&mut b, &|e| key_of(EntityRef::Edge(e)), Some(brep)); let resolved = resolve(i, &b)?; let mut records = seeded_records(&b); let mut attributes = AttributeStore::default(); diff --git a/crates/difftest/src/util.rs b/crates/difftest/src/util.rs index 8819dcfd2..fd08b1a10 100644 --- a/crates/difftest/src/util.rs +++ b/crates/difftest/src/util.rs @@ -1,8 +1,9 @@ //! Small conversions shared by the unit runners in [`crate::units`]. +use solidcore::geom::object::ObjectRef; use solidcore::math::{Point2, Vec3}; use solidcore::topology::brep_cache::{arena_identity, CacheObject}; -use solidcore::topology::Brep; +use solidcore::topology::{Brep, EdgeId, FaceId}; /// A JSON `[x, y, z]` as a [`Vec3`]. #[must_use] @@ -182,19 +183,38 @@ fn nurb_bits(b: &solidcore::nurbs::b_spline_surface::BSplineSurface) -> Option ObjectRef, + brep: Option, +) { let edges: Vec<_> = b.edges().ids().collect(); for id in edges { if let Some(curve) = b.edge_mut(id).ok().and_then(|e| e.curve.as_mut()) { - let _ = curve.set_owner( - Some(arena_identity(CacheObject::Edge(id))), - Some(arena_identity(CacheObject::Brep)), - ); + let _ = curve.set_owner(Some(edge_key(id)), brep); } } +} + +/// Gives every face surface of an imported B-rep its face as owner, under `face_key` +/// (as [`own_edge_curves`] for edges). +pub fn own_face_surfaces(b: &mut Brep, face_key: &dyn Fn(FaceId) -> ObjectRef) { let faces: Vec<_> = b.faces().ids().collect(); for id in faces { if let Some(surface) = b.face_mut(id).ok().and_then(|f| f.surface.as_mut()) { - let _ = surface.set_owner(Some(arena_identity(CacheObject::Face(id)))); + let _ = surface.set_owner(Some(face_key(id))); } } }