Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Fix fillets around tiny rounded-rectangle end edges (#2506)

Colin Faulkinghame1268c6ad965
diff --git a/ROADMAP.md b/ROADMAP.md
index fc02e7f623..b4fc0c9c02 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -52,7 +52,7 @@ PCB / Package, Render, Animation, Simulation, Manufacture/CAM, Drawings.
| M0 | Vertical slice | done | — |
| M1 | Sketch depth: command coverage implemented — projection/intersect/include as linked geometry (auto-project on faces, lost-reference warnings, break link), full SKETCH create/modify set (slots, polygons, tangent arcs/circles, ellipse, fit/control splines, conic, text, trim/extend/break, fillet/chamfer, offset, mirror, patterns, move/scale, blend curve, centerline), constraints incl. curvature and polygon with over-constraint refusal, driven/arc-length/linear-diameter dimensions, AutoConstrain, DXF/SVG insert, 3D sketch curves (Project To Surface, Intersection Curve, Isoparametric Curve, Spun Profile), exact free-form profiles (B-spline/NURBS edges, any spline degree, curves cut by crossings), sweeps and pipes along 3D sketch curves, canvases and decals, curvature combs. Exact free-form Extend and certified associative offsets now preserve geometry and IDs through edits, deletion and reopen. Occurrence-frame 3D wires now store explicit coordinate spaces and retain points and analytic fits through moves, refresh, undo and reopen. Constructive sketch solving (Owen 1991, Fudos & Hoffmann 1997) ahead of the numerical solver: points and rigid clusters are placed on the branch the sketch had, so dimension edits and drags keep their solution; edits that would turn a sketch over are refused; drags re-solve only the sketch per frame. Remaining workflow repairs: mixed offset junctions, legacy natural-spline seams, and damaged legacy wire links lacking frame provenance | in progress | 4 |
| M2 | Robust modelling: coplanar booleans in the kernel, holes (placed on faces and on sketch points), threads (cosmetic, then modelled), patterns, mirror, shell, draft, split, construction geometry | in progress | 16 |
-| M3 | General fillets and chamfers (curved edges, chains, vertex blends); saddle rolling-ball surfaces now use continuous seam sections and arc-length fitting with shared contact boundaries and bounded accuracy checks | in progress | 30 |
+| M3 | General fillets and chamfers (curved edges, chains, vertex blends); saddle rolling-ball surfaces now use continuous seam sections and arc-length fitting with shared contact boundaries and bounded accuracy checks; tiny rim edges remain selected instead of nearby wall seams when filleting (#2498) | in progress | 30 |
| M4 | Files: STEP import (done — [docs/step-import.md](docs/step-import.md)), FreeCAD/Rhino solids through cadmpeg (done, desktop and CLI), 3MF export and 3MF/STL import as mesh bodies (done), 3MF with B-rep face tags ([docs/formats/3mf-face-tags.md](docs/formats/3mf-face-tags.md), done), constant-section parametric mesh reconstruction, DXF sketches, OBJ import | in progress | 6 |
| M5 | Persistent naming of faces and edges (docs/book/src/dev/naming.md): faces named from their exact kernel-reported history (sketch curve sides, caps, revolve sections, primitive sides, blends, shell inner walls, pattern/mirror copies; split pieces told apart by the faces around them, lumps of a cut body named after their faces), edges by their faces; fillets/chamfers, sketches on faces, shell/draft/offset/replace faces, hole placements, joint origins and face appearances resolve by name first and warn when the entity split or vanished: done. sheet metal edges by base sketch line and flange side, shell inner faces, sweep and loft roles: done. kernel-reported face history: done (merged faces answer to every name; operations without history yet fall back to geometric names, flagged unverified; format 14 keeps older designs' geometric names). Left: history through sheet metal, plastic, surface and emboss features; FaceSource certificates through history | in progress | 20 |
| M6 | UI depth: selection feedback and origin (done), timeline editing (done: hover and selection highlight modifier faces, including fillets and chamfers; edit feature, history marker drag, dependency-checked single and multi-item reorder, suppress, rename, delete with dependents, re-resolved references; redefining selections refreshes persistent edge/face references while retaining feature identity and dimension names; optional compact named left feature history with rollback bar, multi-selection and persistent folders above the parts browser), right-docked dialogs (done), live previews for every feature dialog (done), keyboard-first commands with on-canvas value boxes and sketch inline dimensions (done), drag manipulators with automatic join/cut (done: extrude incl. two sides, fillet, shell, hole depth, move, pattern spacing, revolve rotator, extrude taper), dark theme (done), right-click menu with Repeat (done), measure tool (done), section analysis (done), selection filter (done), drag-solve of sketch points (done); appearance controls now preserve body/face/component targeting, named transparent looks, reuse/search and override removal; preferences | in progress | 6 |
diff --git a/crates/kernel/src/blend.rs b/crates/kernel/src/blend.rs
index 7df4951442..484a95e28d 100644
--- a/crates/kernel/src/blend.rs
+++ b/crates/kernel/src/blend.rs
@@ -1756,6 +1756,9 @@ fn loop_split(cur: &Body, pts: &[Vec3]) -> Result<Option<(Vec<Vec<Vec3>>, Vec<Ve
// Each point's edge. A point on a vertex is as near to the edges meeting there (a circle
// and a cylinder's seam line): prefer one on a planar face's boundary.
let polys = cur.edges(tol)?;
+ // Only break actual distance ties. The tessellation tolerance can exceed half a short
+ // rim edge's length: using it here would pick a nearby wall seam instead (#2498).
+ let tie_tol = (size * 1e-7).max(1e-9);
let planar_edge: std::collections::HashSet<mt::EdgeID> = solid
.face_iter()
.filter(|f| matches!(f.oriented_surface(), mt::Surface::Plane(_)))
@@ -1769,7 +1772,7 @@ fn loop_split(cur: &Body, pts: &[Vec3]) -> Result<Option<(Vec<Vec<Vec3>>, Vec<Ve
if best > size * 0.05 + 1e-3 {
return Ok(None);
}
- let near: Vec<&mt::Edge> = dists.iter().filter(|x| x.1 <= best + tol).filter_map(|x| all.get(x.0)).collect();
+ let near: Vec<&mt::Edge> = dists.iter().filter(|x| x.1 <= best + tie_tol).filter_map(|x| all.get(x.0)).collect();
let Some(e) = near.iter().find(|e| planar_edge.contains(&e.id())).or(near.first()) else { return Ok(None) };
per.push((*p, e.id()));
}
diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs
index 6b3e321f61..69840f9da0 100644
--- a/crates/kernel/src/tests.rs
+++ b/crates/kernel/src/tests.rs
@@ -1976,6 +1976,53 @@ fn fillet_smooth_arc_and_line_loop_keeps_exact_removal() {
assert!(rel(removed, want) < 1e-3, "{removed} vs {want}");
}
+#[test]
+fn fillet_rounded_rectangle_with_tiny_end_edges() {
+ // #2498: the 4.29 mm corners leave 0.02 mm straight edges on an 8.6 mm end.
+ let (w, h, r, height) = (26.4, 8.6, 4.29, 8.4);
+ let p = |x, y| Vec2::new(10.0 + x, 10.0 + y);
+ let outline = Loop2 {
+ segs: vec![
+ Seg2::Line { a: p(r, 0.0), b: p(w - r, 0.0) },
+ Seg2::Arc { center: p(w - r, r), radius: r, start: -PI / 2.0, sweep: PI / 2.0 },
+ Seg2::Line { a: p(w, r), b: p(w, h - r) },
+ Seg2::Arc { center: p(w - r, h - r), radius: r, start: 0.0, sweep: PI / 2.0 },
+ Seg2::Line { a: p(w - r, h), b: p(r, h) },
+ Seg2::Arc { center: p(r, h - r), radius: r, start: PI / 2.0, sweep: PI / 2.0 },
+ Seg2::Line { a: p(0.0, h - r), b: p(0.0, r) },
+ Seg2::Arc { center: p(r, r), radius: r, start: PI, sweep: PI / 2.0 },
+ ],
+ };
+ let body = extrude(&Plane::XY, &[Region2 { outer: outline, holes: vec![] }], 0.0, height).unwrap().pop().unwrap();
+ let picks = [
+ Vec3::new(23.2, 10.0, 8.4),
+ Vec3::new(35.14348809129028, 11.25651190870971, 8.4),
+ Vec3::new(11.256511908709715, 11.256511908709712, 8.4),
+ Vec3::new(10.0, 14.3, 8.4),
+ Vec3::new(11.256511908709713, 17.343488091290293, 8.4),
+ Vec3::new(23.2, 18.6, 8.4),
+ Vec3::new(35.14348809129028, 17.34348809129029, 8.4),
+ Vec3::new(36.4, 14.3, 8.4),
+ ];
+ let radius = 2.0;
+ // Pappus: the removed cross-section swept along the straight sides and four quarters.
+ let area = radius * radius * (1.0 - PI / 4.0);
+ let centroid = radius * (10.0 - 3.0 * PI) / (3.0 * (4.0 - PI));
+ let removed = area * (2.0 * (w + h - 4.0 * r) + 2.0 * PI * (r - centroid));
+ let fine = |b: &Body| b.tessellate_with(1e-4, true).unwrap().measure().volume;
+ let initial = fine(&body);
+ // Every rim edge, the tiny end alone (tangent chain), and the opposite selection order.
+ for selection in [picks.to_vec(), vec![picks[3]], picks.into_iter().rev().collect()] {
+ let blended = fillet(&body, &selection, radius).unwrap();
+ assert!(blended.validity().is_empty(), "{:?}", blended.validity());
+ assert_eq!(blended.crossed_face_loops().unwrap(), 0);
+ assert_eq!((blended.face_count(), blended.edge_count(), blended.vertex_count()), (18, 40, 24));
+ let actual = initial - fine(&blended);
+ assert!(rel(actual, removed) < 1e-3, "{actual} vs {removed}");
+ }
+ assert!(fillet(&body, &picks, 9.0).is_err());
+}
+
#[test]
fn fillet_sharp_arc_and_arc_loop() {
use solidcraft_geom::Seg2;