From 2f5bb8bcdc618200ee6630f48b567a21ef2bd5bd Mon Sep 17 00:00:00 2001 From: Erlis Vidal Date: Fri, 23 Oct 2026 21:07:34 -0400 Subject: [PATCH] fix: sweep store records face tolerances on the surfaces it owns SweepStore::insert_body owns each face surface under the store's identities but did not record the face's tolerance on it, as every other place that gives a face its surface does (Brep::sync_face_surface_tolerance). A query on the store's B-rep that reaches a face through its surface (SmSurface::GetFace()->GetTolerance) then stopped at the unported SmFace::GetTolerance (topology.face_p2). Co-Authored-By: Claude Opus 5.5 (1M context) --- .../src/sweep/topology_sweep/store.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/solidcore/src/sweep/topology_sweep/store.rs b/crates/solidcore/src/sweep/topology_sweep/store.rs index a019e9c48..24770512c 100644 --- a/crates/solidcore/src/sweep/topology_sweep/store.rs +++ b/crates/solidcore/src/sweep/topology_sweep/store.rs @@ -502,6 +502,9 @@ impl<'a> SweepStore<'a> { if let Some(s) = &mut b.face_mut(f)?.surface { s.set_owner(Some(self.identities.object(namespace, EntityRef::Face(f)))); } + // the owned surface carries its face's tolerance, as wherever a face gets its + // surface (`SmFace::GetTolerance` through `SmSurface::GetFace`) + b.sync_face_surface_tolerance(f)?; } let entities = std::iter::once(EntityRef::Brep(id)) .chain(b.regions().ids().map(EntityRef::Region)) @@ -1628,6 +1631,25 @@ mod tests { .unwrap(); } + #[test] + fn inserted_breps_record_face_tolerances_on_their_surfaces() { + use crate::surface::plane::Plane; + use crate::surface::surface::Surface; + let mut raw = Brep::new_with_infinite_region().unwrap(); + let shell = raw.add_shell().unwrap(); + let face = raw.add_face(shell).unwrap(); + let record = raw.face_mut(face).unwrap(); + record.surface = Some(Surface::from(Plane::from_normal(Vec3::ZERO, Vec3::Z))); + record.tolerance = 2.5e-4; + let mut store = SweepStore::owned(); + let c = store.insert_kernel(Kernel::default()).unwrap(); + let b = store.insert_brep(c, raw).unwrap(); + let brep = store.brep(b).unwrap(); + let surface = brep.face(face).unwrap().surface.as_ref().unwrap(); + // the store owns the surface under the face: SmSurface::GetFace()->GetTolerance() + assert_eq!(surface.face_zone_tol_3d().unwrap(), Some(2.5e-4)); + } + #[test] fn axis_classification_reaches_the_native_face_boundary() { use crate::curve::line::Line;