[WIP] Add support for rounding line-arc corners#166
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
It looks like the 1.10 test failures are related to Julia internals (type narrowing?) -- maybe an unnecessary Separately, up until now, I've been thinking of CurvilinearPolygon as "DeviceLayout internals" -- not thoroughly documented or tested for direct use (i.e., outside of the SolidModels rendering pipeline), not included in the HTML docs, doesn't use tolerance in |
98e19e6 to
770904b
Compare
I mentioned this caveat in my MR, but worth reiterating here. We probably need a per-corner rounding radius to make it robust - at least for my use case. |
…egion
Implement fillet rounding at vertices where a straight edge meets a circular arc. The existing Rounded style only handled straight-straight corners; line-arc corners were skipped entirely.
New in src/curvilinear.jl:
- edge_type_at_vertex: classifies incoming/outgoing edges as :straight
or a Paths.Turn curve
- rounded_corner_line_arc: bisection solver finds fillet center at the
intersection of a line offset and a circle (R ± r from arc center);
tries both internal and external tangency, validates via T_line position
- to_polygons(CurvilinearPolygon, Rounded): rounds all corners (straight-
straight and line-arc), then discretizes remaining curves with trimming
at fillet tangent points
- to_polygons(CurvilinearRegion, Rounded): rounds exterior and holes
independently before differencing
Test (test/test_line_arc_rounding.jl) covers 13 arc features:
- 10 exterior arcs on a 24×16μm rectangle: sweeps from 60° to 270°,
notches and bumps, all four edges
- 3 interior pie-slice holes (60°, 90°, 120° arcs) via CurvilinearRegion
- G1 continuity check on the rounded output
- Fillet radius larger than arc radius (graceful clamping)
TODOs:
- Solid model pipeline
- Documentation
The bisection bracket (±π/2) failed for arcs where the fillet center was very close to the corner angle, causing rounding to silently skip those corners. Replace the bisection with an analytical line-circle intersection that works for all geometries.
770904b to
90fafb3
Compare
For ordinary Polygons, you can stack poly = Rectangle(1mm, 1mm)
r1_points = [Point(0, 0)mm]
r2_points = [Point(1, 1)mm]
r3_points = [Point(0, 1)mm, Point(1, 0)mm]
r1 = 0.1mm
r2 = 0.2mm
r3 = 0.3mm
rnd1_poly = Rounded(r1; p0=r1_points)(poly)
rnd12_poly = Rounded(r2; p0=r2_points)(rnd1_poly)
rnd123_poly = Rounded(r3; p0=r3_points)(rnd12_poly)This works for rendering to Cell because the inner styled entity is resolved to a Polygon first, and then the outer Unfortunately, to do this, we had to duplicate rounding logic in However, it still won't work for Cell, because the inner entity gets resolved into a Polygon rather than a CurvilinearPolygon. However, once you've added line-arc rounding to function to_polygons(
ent::StyledEntity{T, U, V},
sty::Rounded{S};
atol=_round_atol(S, T),
kwargs...
) where {S, T, U, V <: Rounded}
return to_polygons(
SolidModels.styled_loop(ent.ent, ent.sty),
sty;
atol,
kwargs...
)
endI think ideally the rendering of Rounded entities would always go through CurvilinearPolygon, allowing us to remove the duplicated logic. I would like to fix #47 first, though. |

This PR implements fillet rounding at vertices where a straight edge meets a circular arc. The existing Rounded style only handled straight-straight corners; line-arc corners were skipped entirely.
TODOs: