Add Circle type#258
Conversation
Circle{T} stores center and radius directly instead of constructing an
equal-radii Ellipse. Shared behavior (perimeter, SolidModel
primitive rendering, mesh sizing) moves to a new AbstractEllipse supertype
dispatching through the center/r1/r2/angle accessors; `to_polygons` calls
`circular_arc` directly (rendered geometry is equivalent within tolerance).
Angle-preserving transformations return a
Circle; general transformations still widen to Ellipse. Adds bounds and
perimeter fast paths for Circle.
Breaking for consumers of internals: Circle constructors no longer
return Ellipse; code relying on `Circle(...) isa Ellipse` should use
AbstractEllipse and direct field access should be replaced with
accessors.
Represent Circle exactly as four arcs for curve recovery
A new CurvilinearPolygon(::Circle) constructor builds the circle from four
90-degree Turn arcs meeting at the axis-aligned extreme points, avoiding the
degeneracies of single-curve (constructor dedup, zero-length assert, mod2pi
collapse) and semicircle (OCC split path, collinear-endpoint guard) forms.
Circles now participate in curve recovery through both the unstyled clip path
(_normalize_curved_clip_arg) and the styled path (to_curvilinear), recovering
their arcs through boolean operations instead of warning and discretizing.
Ellipse behavior is unchanged (unequal radii are not representable as arcs).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This is breaking for anything downstream that assumes the output of The main thing we want is for circles to participate in curve recovery, and the rendering shortcut is also nice. But we can just check if the radii are (exactly) equal when we want special handling of circles. This isn't measurably worse performance-wise than using dispatch, and actually avoids the instability for generic transformations and (potentially) one more type for union splitting. |
Close #251. Adds
AbstractEllipseabstract type and makes bothEllipseand newCircleconcrete subtypes. This allowsCirclemethods to take fast paths, as well as participate in curve recovery by resolving to a CurvilinearPolygon with four 90 degree arcs. (CurvilinearPolygon doesn't like single closed curves (see #256), and SolidModel wants arcs strictly less than 180 degrees anyway; four arcs is also nice because it's equivalent to a fully rounded square.)